nsIHttpProtocolHandler.idl (7979B)
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #include "nsIProxiedProtocolHandler.idl" 7 8 %{C++ 9 namespace mozilla { 10 namespace net { 11 class HSTSDataCallbackWrapper; 12 } 13 } 14 %} 15 16 native HSTSDataCallbackWrapperAlreadyAddRefed(RefPtr<mozilla::net::HSTSDataCallbackWrapper>); 17 18 [scriptable, builtinclass, uuid(c48126d9-2ddd-485b-a51a-378e917e75f8)] 19 interface nsIHttpProtocolHandler : nsIProxiedProtocolHandler 20 { 21 /** 22 * Get the HTTP advertised user agent string. 23 */ 24 [must_use] readonly attribute ACString userAgent; 25 26 /** 27 * Get the HTTP advertised user agent string. 28 */ 29 [must_use] readonly attribute ACString rfpUserAgent; 30 31 /** 32 * Get the application name. 33 * 34 * @return The name of this application (eg. "Mozilla"). 35 */ 36 [must_use] readonly attribute ACString appName; 37 38 /** 39 * Get the application version string. 40 * 41 * @return The complete version (major and minor) string. (eg. "5.0") 42 */ 43 [must_use] readonly attribute ACString appVersion; 44 45 /** 46 * Get the current platform. 47 * 48 * @return The platform this application is running on 49 * (eg. "Windows", "Macintosh", "X11") 50 */ 51 [must_use] readonly attribute ACString platform; 52 53 /** 54 * Get the current oscpu. 55 * 56 * @return The oscpu this application is running on 57 */ 58 [must_use] readonly attribute ACString oscpu; 59 60 /** 61 * Get the application comment misc portion. 62 */ 63 [must_use] readonly attribute ACString misc; 64 65 /** 66 * Get the Alt-Svc cache keys (used for testing). 67 */ 68 [must_use] readonly attribute Array<ACString> altSvcCacheKeys; 69 70 /** 71 * Get the auth cache keys (used for testing). 72 */ 73 [must_use] readonly attribute Array<ACString> authCacheKeys; 74 75 /** 76 * This function is used to ensure HSTS data storage is ready to read after 77 * the returned promise is resolved. 78 * Note that this function should only used for testing. 79 * See bug 1521729 for more details. 80 */ 81 [implicit_jscontext] 82 Promise EnsureHSTSDataReady(); 83 84 /** 85 * A C++ friendly version of EnsureHSTSDataReady 86 */ 87 [noscript] 88 void EnsureHSTSDataReadyNative(in HSTSDataCallbackWrapperAlreadyAddRefed aCallback); 89 90 /* 91 * Clears the CORS preflight cache. 92 */ 93 void clearCORSPreflightCache(); 94 }; 95 96 %{C++ 97 // ----------- Categories ----------- 98 /** 99 * At initialization time, the HTTP handler will initialize each service 100 * registered under this category: 101 */ 102 #define NS_HTTP_STARTUP_CATEGORY "http-startup-category" 103 104 // ----------- Observer topics ----------- 105 /** 106 * nsIObserver notification corresponding to startup category. Services 107 * registered under the startup category will receive this observer topic at 108 * startup if they implement nsIObserver. The "subject" of the notification 109 * is the nsIHttpProtocolHandler instance. 110 */ 111 #define NS_HTTP_STARTUP_TOPIC "http-startup" 112 113 /** 114 * Called when asyncOpen synchronously failes e.g. because of any synchronously 115 * performed security checks. This only fires on the child process, but if 116 * needed can be implemented also on the parent process. 117 */ 118 #define NS_HTTP_ON_FAILED_OPENING_REQUEST_TOPIC "http-on-failed-opening-request" 119 120 /** 121 * This observer topic is notified when an HTTP channel is opened. 122 * It is similar to http-on-modify-request, except that 123 * 1) The notification is guaranteed to occur before on-modify-request, during 124 * the AsyncOpen call itself. 125 * 2) It only occurs for the initial open of a channel, not for internal 126 * asyncOpens that happen during redirects, etc. 127 * 3) Some information (most notably nsIProxiedChannel.proxyInfo) may not be set 128 * on the channel object yet. 129 * 130 * The "subject" of the notification is the nsIHttpChannel instance. 131 * 132 * Generally the 'http-on-modify-request' notification is preferred unless the 133 * synchronous, during-asyncOpen behavior that this notification provides is 134 * required. 135 */ 136 #define NS_HTTP_ON_OPENING_REQUEST_TOPIC "http-on-opening-request" 137 138 /** 139 * This observer topic is notified when a document channel is opened. 140 * It is similar to http-on-opening-request. 141 */ 142 #define NS_DOCUMENT_ON_OPENING_REQUEST_TOPIC "document-on-opening-request" 143 144 /** 145 * Before an HTTP request is sent to the server, this observer topic is 146 * notified. The observer of this topic can then choose to set any additional 147 * headers for this request before the request is actually sent to the server. 148 * The "subject" of the notification is the nsIHttpChannel instance. 149 */ 150 #define NS_HTTP_ON_MODIFY_REQUEST_TOPIC "http-on-modify-request" 151 152 /** 153 * Same as http-on-modify-request, but called before the cookie header is set on 154 * the channel. 155 * This allows observers to set cookies via the cookie service to be included in 156 * the request header. 157 * http-on-modify-request is too late for this use-case since the cookie header 158 * has already been populated at that point. 159 */ 160 #define NS_HTTP_ON_MODIFY_REQUEST_BEFORE_COOKIES_TOPIC "http-on-modify-request-before-cookies" 161 162 /** 163 * Before an HTTP request is sent to the server via a document channel this 164 * observer topic is notified. 165 * It is similar to http-on-modify-request. 166 */ 167 #define NS_DOCUMENT_ON_MODIFY_REQUEST_TOPIC "document-on-modify-request" 168 169 /** 170 * Before an HTTP connection to the server is created, this observer topic is 171 * notified. This observer happens after HSTS upgrades, etc. are set, providing 172 * access to the full set of request headers. The observer of this topic can 173 * choose to set any additional headers for this request before the request is 174 * actually sent to the server. The "subject" of the notification is the 175 * nsIHttpChannel instance. 176 */ 177 #define NS_HTTP_ON_BEFORE_CONNECT_TOPIC "http-on-before-connect" 178 179 /** 180 * After an HTTP server response is received, this observer topic is notified. 181 * The observer of this topic can interrogate the response. The "subject" of 182 * the notification is the nsIHttpChannel instance. 183 */ 184 #define NS_HTTP_ON_EXAMINE_RESPONSE_TOPIC "http-on-examine-response" 185 186 /** 187 * This notification is triggered after the examination of the response header. 188 * The observer of this topic can interrogate the response. The "subject" of 189 * the notification is the nsIHttpChannel instance. 190 */ 191 #define NS_HTTP_ON_AFTER_EXAMINE_RESPONSE_TOPIC "http-on-after-examine-response" 192 193 /** 194 * The observer of this topic is notified after the received HTTP response 195 * is merged with data from the browser cache. This means that, among other 196 * things, the Content-Type header will be set correctly. 197 */ 198 #define NS_HTTP_ON_EXAMINE_MERGED_RESPONSE_TOPIC "http-on-examine-merged-response" 199 200 /** 201 * The observer of this topic is notified about a background revalidation that 202 * started by hitting a request that fell into stale-while-revalidate window. 203 * This notification points to the channel that performed the revalidation and 204 * after this notification the cache entry has been validated or updated. 205 */ 206 #define NS_HTTP_ON_BACKGROUND_REVALIDATION "http-on-background-revalidation" 207 208 /** 209 * The observer of this topic is notified before data is read from the cache. 210 * The notification is sent if and only if there is no network communication 211 * at all. 212 */ 213 #define NS_HTTP_ON_EXAMINE_CACHED_RESPONSE_TOPIC "http-on-examine-cached-response" 214 215 /** 216 * This topic is notified for every http channel before calling 217 * OnStopRequest on its listener. 218 */ 219 #define NS_HTTP_ON_BEFORE_STOP_REQUEST_TOPIC "http-on-before-stop-request" 220 221 /** 222 * This topic is notified for every http channel right after it called 223 * OnStopRequest on its listener, regardless whether it was finished 224 * successfully, failed or has been canceled. 225 */ 226 #define NS_HTTP_ON_STOP_REQUEST_TOPIC "http-on-stop-request" 227 228 %}