1*6777b538SAndroid Build Coastguard Worker // Copyright 2012 The Chromium Authors 2*6777b538SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*6777b538SAndroid Build Coastguard Worker // found in the LICENSE file. 4*6777b538SAndroid Build Coastguard Worker 5*6777b538SAndroid Build Coastguard Worker #ifndef NET_URL_REQUEST_URL_REQUEST_H_ 6*6777b538SAndroid Build Coastguard Worker #define NET_URL_REQUEST_URL_REQUEST_H_ 7*6777b538SAndroid Build Coastguard Worker 8*6777b538SAndroid Build Coastguard Worker #include <stdint.h> 9*6777b538SAndroid Build Coastguard Worker 10*6777b538SAndroid Build Coastguard Worker #include <memory> 11*6777b538SAndroid Build Coastguard Worker #include <optional> 12*6777b538SAndroid Build Coastguard Worker #include <string> 13*6777b538SAndroid Build Coastguard Worker #include <string_view> 14*6777b538SAndroid Build Coastguard Worker #include <vector> 15*6777b538SAndroid Build Coastguard Worker 16*6777b538SAndroid Build Coastguard Worker #include "base/containers/flat_set.h" 17*6777b538SAndroid Build Coastguard Worker #include "base/memory/raw_ptr.h" 18*6777b538SAndroid Build Coastguard Worker #include "base/memory/weak_ptr.h" 19*6777b538SAndroid Build Coastguard Worker #include "base/supports_user_data.h" 20*6777b538SAndroid Build Coastguard Worker #include "base/threading/thread_checker.h" 21*6777b538SAndroid Build Coastguard Worker #include "base/time/time.h" 22*6777b538SAndroid Build Coastguard Worker #include "base/types/pass_key.h" 23*6777b538SAndroid Build Coastguard Worker #include "base/values.h" 24*6777b538SAndroid Build Coastguard Worker #include "net/base/auth.h" 25*6777b538SAndroid Build Coastguard Worker #include "net/base/completion_repeating_callback.h" 26*6777b538SAndroid Build Coastguard Worker #include "net/base/idempotency.h" 27*6777b538SAndroid Build Coastguard Worker #include "net/base/ip_endpoint.h" 28*6777b538SAndroid Build Coastguard Worker #include "net/base/isolation_info.h" 29*6777b538SAndroid Build Coastguard Worker #include "net/base/load_flags.h" 30*6777b538SAndroid Build Coastguard Worker #include "net/base/load_states.h" 31*6777b538SAndroid Build Coastguard Worker #include "net/base/load_timing_info.h" 32*6777b538SAndroid Build Coastguard Worker #include "net/base/net_error_details.h" 33*6777b538SAndroid Build Coastguard Worker #include "net/base/net_errors.h" 34*6777b538SAndroid Build Coastguard Worker #include "net/base/net_export.h" 35*6777b538SAndroid Build Coastguard Worker #include "net/base/network_delegate.h" 36*6777b538SAndroid Build Coastguard Worker #include "net/base/proxy_chain.h" 37*6777b538SAndroid Build Coastguard Worker #include "net/base/request_priority.h" 38*6777b538SAndroid Build Coastguard Worker #include "net/base/upload_progress.h" 39*6777b538SAndroid Build Coastguard Worker #include "net/cookies/canonical_cookie.h" 40*6777b538SAndroid Build Coastguard Worker #include "net/cookies/cookie_partition_key.h" 41*6777b538SAndroid Build Coastguard Worker #include "net/cookies/cookie_setting_override.h" 42*6777b538SAndroid Build Coastguard Worker #include "net/cookies/site_for_cookies.h" 43*6777b538SAndroid Build Coastguard Worker #include "net/dns/public/secure_dns_policy.h" 44*6777b538SAndroid Build Coastguard Worker #include "net/filter/source_stream.h" 45*6777b538SAndroid Build Coastguard Worker #include "net/http/http_raw_request_headers.h" 46*6777b538SAndroid Build Coastguard Worker #include "net/http/http_request_headers.h" 47*6777b538SAndroid Build Coastguard Worker #include "net/http/http_response_headers.h" 48*6777b538SAndroid Build Coastguard Worker #include "net/http/http_response_info.h" 49*6777b538SAndroid Build Coastguard Worker #include "net/log/net_log_event_type.h" 50*6777b538SAndroid Build Coastguard Worker #include "net/log/net_log_source.h" 51*6777b538SAndroid Build Coastguard Worker #include "net/log/net_log_with_source.h" 52*6777b538SAndroid Build Coastguard Worker #include "net/net_buildflags.h" 53*6777b538SAndroid Build Coastguard Worker #include "net/socket/connection_attempts.h" 54*6777b538SAndroid Build Coastguard Worker #include "net/socket/socket_tag.h" 55*6777b538SAndroid Build Coastguard Worker #include "net/traffic_annotation/network_traffic_annotation.h" 56*6777b538SAndroid Build Coastguard Worker #include "net/url_request/redirect_info.h" 57*6777b538SAndroid Build Coastguard Worker #include "net/url_request/referrer_policy.h" 58*6777b538SAndroid Build Coastguard Worker #include "url/gurl.h" 59*6777b538SAndroid Build Coastguard Worker #include "url/origin.h" 60*6777b538SAndroid Build Coastguard Worker 61*6777b538SAndroid Build Coastguard Worker namespace net { 62*6777b538SAndroid Build Coastguard Worker 63*6777b538SAndroid Build Coastguard Worker class CookieOptions; 64*6777b538SAndroid Build Coastguard Worker class CookieInclusionStatus; 65*6777b538SAndroid Build Coastguard Worker class IOBuffer; 66*6777b538SAndroid Build Coastguard Worker struct LoadTimingInfo; 67*6777b538SAndroid Build Coastguard Worker struct RedirectInfo; 68*6777b538SAndroid Build Coastguard Worker class SSLCertRequestInfo; 69*6777b538SAndroid Build Coastguard Worker class SSLInfo; 70*6777b538SAndroid Build Coastguard Worker class SSLPrivateKey; 71*6777b538SAndroid Build Coastguard Worker struct TransportInfo; 72*6777b538SAndroid Build Coastguard Worker class UploadDataStream; 73*6777b538SAndroid Build Coastguard Worker class URLRequestContext; 74*6777b538SAndroid Build Coastguard Worker class URLRequestJob; 75*6777b538SAndroid Build Coastguard Worker class X509Certificate; 76*6777b538SAndroid Build Coastguard Worker 77*6777b538SAndroid Build Coastguard Worker //----------------------------------------------------------------------------- 78*6777b538SAndroid Build Coastguard Worker // A class representing the asynchronous load of a data stream from an URL. 79*6777b538SAndroid Build Coastguard Worker // 80*6777b538SAndroid Build Coastguard Worker // The lifetime of an instance of this class is completely controlled by the 81*6777b538SAndroid Build Coastguard Worker // consumer, and the instance is not required to live on the heap or be 82*6777b538SAndroid Build Coastguard Worker // allocated in any special way. It is also valid to delete an URLRequest 83*6777b538SAndroid Build Coastguard Worker // object during the handling of a callback to its delegate. Of course, once 84*6777b538SAndroid Build Coastguard Worker // the URLRequest is deleted, no further callbacks to its delegate will occur. 85*6777b538SAndroid Build Coastguard Worker // 86*6777b538SAndroid Build Coastguard Worker // NOTE: All usage of all instances of this class should be on the same thread. 87*6777b538SAndroid Build Coastguard Worker // 88*6777b538SAndroid Build Coastguard Worker class NET_EXPORT URLRequest : public base::SupportsUserData { 89*6777b538SAndroid Build Coastguard Worker public: 90*6777b538SAndroid Build Coastguard Worker // Max number of http redirects to follow. The Fetch spec says: "If 91*6777b538SAndroid Build Coastguard Worker // request's redirect count is twenty, return a network error." 92*6777b538SAndroid Build Coastguard Worker // https://fetch.spec.whatwg.org/#http-redirect-fetch 93*6777b538SAndroid Build Coastguard Worker static constexpr int kMaxRedirects = 20; 94*6777b538SAndroid Build Coastguard Worker 95*6777b538SAndroid Build Coastguard Worker // The delegate's methods are called from the message loop of the thread 96*6777b538SAndroid Build Coastguard Worker // on which the request's Start() method is called. See above for the 97*6777b538SAndroid Build Coastguard Worker // ordering of callbacks. 98*6777b538SAndroid Build Coastguard Worker // 99*6777b538SAndroid Build Coastguard Worker // The callbacks will be called in the following order: 100*6777b538SAndroid Build Coastguard Worker // Start() 101*6777b538SAndroid Build Coastguard Worker // - OnConnected* (zero or more calls, see method comment) 102*6777b538SAndroid Build Coastguard Worker // - OnCertificateRequested* (zero or more calls, if the SSL server and/or 103*6777b538SAndroid Build Coastguard Worker // SSL proxy requests a client certificate for authentication) 104*6777b538SAndroid Build Coastguard Worker // - OnSSLCertificateError* (zero or one call, if the SSL server's 105*6777b538SAndroid Build Coastguard Worker // certificate has an error) 106*6777b538SAndroid Build Coastguard Worker // - OnReceivedRedirect* (zero or more calls, for the number of redirects) 107*6777b538SAndroid Build Coastguard Worker // - OnAuthRequired* (zero or more calls, for the number of 108*6777b538SAndroid Build Coastguard Worker // authentication failures) 109*6777b538SAndroid Build Coastguard Worker // - OnResponseStarted 110*6777b538SAndroid Build Coastguard Worker // Read() initiated by delegate 111*6777b538SAndroid Build Coastguard Worker // - OnReadCompleted* (zero or more calls until all data is read) 112*6777b538SAndroid Build Coastguard Worker // 113*6777b538SAndroid Build Coastguard Worker // Read() must be called at least once. Read() returns bytes read when it 114*6777b538SAndroid Build Coastguard Worker // completes immediately, and a negative error value if an IO is pending or if 115*6777b538SAndroid Build Coastguard Worker // there is an error. 116*6777b538SAndroid Build Coastguard Worker class NET_EXPORT Delegate { 117*6777b538SAndroid Build Coastguard Worker public: 118*6777b538SAndroid Build Coastguard Worker Delegate() = default; 119*6777b538SAndroid Build Coastguard Worker 120*6777b538SAndroid Build Coastguard Worker // Forbid copy and assign to prevent slicing. 121*6777b538SAndroid Build Coastguard Worker Delegate(const Delegate&) = delete; 122*6777b538SAndroid Build Coastguard Worker Delegate& operator=(const Delegate&) = delete; 123*6777b538SAndroid Build Coastguard Worker 124*6777b538SAndroid Build Coastguard Worker // Called each time a connection is obtained, before any data is sent. 125*6777b538SAndroid Build Coastguard Worker // 126*6777b538SAndroid Build Coastguard Worker // |request| is never nullptr. Caller retains ownership. 127*6777b538SAndroid Build Coastguard Worker // 128*6777b538SAndroid Build Coastguard Worker // |info| describes the newly-obtained connection. 129*6777b538SAndroid Build Coastguard Worker // 130*6777b538SAndroid Build Coastguard Worker // This may be called several times if the request creates multiple HTTP 131*6777b538SAndroid Build Coastguard Worker // transactions, e.g. if the request is redirected. It may also be called 132*6777b538SAndroid Build Coastguard Worker // several times per transaction, e.g. if the connection is retried, after 133*6777b538SAndroid Build Coastguard Worker // each HTTP auth challenge, or for split HTTP range requests. 134*6777b538SAndroid Build Coastguard Worker // 135*6777b538SAndroid Build Coastguard Worker // If this returns an error, the transaction will stop. The transaction 136*6777b538SAndroid Build Coastguard Worker // will continue when the |callback| is run. If run with an error, the 137*6777b538SAndroid Build Coastguard Worker // transaction will fail. 138*6777b538SAndroid Build Coastguard Worker virtual int OnConnected(URLRequest* request, 139*6777b538SAndroid Build Coastguard Worker const TransportInfo& info, 140*6777b538SAndroid Build Coastguard Worker CompletionOnceCallback callback); 141*6777b538SAndroid Build Coastguard Worker 142*6777b538SAndroid Build Coastguard Worker // Called upon receiving a redirect. The delegate may call the request's 143*6777b538SAndroid Build Coastguard Worker // Cancel method to prevent the redirect from being followed. Since there 144*6777b538SAndroid Build Coastguard Worker // may be multiple chained redirects, there may also be more than one 145*6777b538SAndroid Build Coastguard Worker // redirect call. 146*6777b538SAndroid Build Coastguard Worker // 147*6777b538SAndroid Build Coastguard Worker // When this function is called, the request will still contain the 148*6777b538SAndroid Build Coastguard Worker // original URL, the destination of the redirect is provided in 149*6777b538SAndroid Build Coastguard Worker // |redirect_info.new_url|. If the delegate does not cancel the request 150*6777b538SAndroid Build Coastguard Worker // and |*defer_redirect| is false, then the redirect will be followed, and 151*6777b538SAndroid Build Coastguard Worker // the request's URL will be changed to the new URL. Otherwise if the 152*6777b538SAndroid Build Coastguard Worker // delegate does not cancel the request and |*defer_redirect| is true, then 153*6777b538SAndroid Build Coastguard Worker // the redirect will be followed once FollowDeferredRedirect is called 154*6777b538SAndroid Build Coastguard Worker // on the URLRequest. 155*6777b538SAndroid Build Coastguard Worker // 156*6777b538SAndroid Build Coastguard Worker // The caller must set |*defer_redirect| to false, so that delegates do not 157*6777b538SAndroid Build Coastguard Worker // need to set it if they are happy with the default behavior of not 158*6777b538SAndroid Build Coastguard Worker // deferring redirect. 159*6777b538SAndroid Build Coastguard Worker virtual void OnReceivedRedirect(URLRequest* request, 160*6777b538SAndroid Build Coastguard Worker const RedirectInfo& redirect_info, 161*6777b538SAndroid Build Coastguard Worker bool* defer_redirect); 162*6777b538SAndroid Build Coastguard Worker 163*6777b538SAndroid Build Coastguard Worker // Called when we receive an authentication failure. The delegate should 164*6777b538SAndroid Build Coastguard Worker // call request->SetAuth() with the user's credentials once it obtains them, 165*6777b538SAndroid Build Coastguard Worker // or request->CancelAuth() to cancel the login and display the error page. 166*6777b538SAndroid Build Coastguard Worker // When it does so, the request will be reissued, restarting the sequence 167*6777b538SAndroid Build Coastguard Worker // of On* callbacks. 168*6777b538SAndroid Build Coastguard Worker // 169*6777b538SAndroid Build Coastguard Worker // NOTE: If auth_info.scheme is AUTH_SCHEME_NEGOTIATE on ChromeOS, this 170*6777b538SAndroid Build Coastguard Worker // method should not call SetAuth(). Instead, it should show ChromeOS 171*6777b538SAndroid Build Coastguard Worker // specific UI and cancel the request. (See b/260522530). 172*6777b538SAndroid Build Coastguard Worker virtual void OnAuthRequired(URLRequest* request, 173*6777b538SAndroid Build Coastguard Worker const AuthChallengeInfo& auth_info); 174*6777b538SAndroid Build Coastguard Worker 175*6777b538SAndroid Build Coastguard Worker // Called when we receive an SSL CertificateRequest message for client 176*6777b538SAndroid Build Coastguard Worker // authentication. The delegate should call 177*6777b538SAndroid Build Coastguard Worker // request->ContinueWithCertificate() with the client certificate the user 178*6777b538SAndroid Build Coastguard Worker // selected and its private key, or request->ContinueWithCertificate(NULL, 179*6777b538SAndroid Build Coastguard Worker // NULL) 180*6777b538SAndroid Build Coastguard Worker // to continue the SSL handshake without a client certificate. 181*6777b538SAndroid Build Coastguard Worker virtual void OnCertificateRequested(URLRequest* request, 182*6777b538SAndroid Build Coastguard Worker SSLCertRequestInfo* cert_request_info); 183*6777b538SAndroid Build Coastguard Worker 184*6777b538SAndroid Build Coastguard Worker // Called when using SSL and the server responds with a certificate with 185*6777b538SAndroid Build Coastguard Worker // an error, for example, whose common name does not match the common name 186*6777b538SAndroid Build Coastguard Worker // we were expecting for that host. The delegate should either do the 187*6777b538SAndroid Build Coastguard Worker // safe thing and Cancel() the request or decide to proceed by calling 188*6777b538SAndroid Build Coastguard Worker // ContinueDespiteLastError(). cert_error is a ERR_* error code 189*6777b538SAndroid Build Coastguard Worker // indicating what's wrong with the certificate. 190*6777b538SAndroid Build Coastguard Worker // If |fatal| is true then the host in question demands a higher level 191*6777b538SAndroid Build Coastguard Worker // of security (due e.g. to HTTP Strict Transport Security, user 192*6777b538SAndroid Build Coastguard Worker // preference, or built-in policy). In this case, errors must not be 193*6777b538SAndroid Build Coastguard Worker // bypassable by the user. 194*6777b538SAndroid Build Coastguard Worker virtual void OnSSLCertificateError(URLRequest* request, 195*6777b538SAndroid Build Coastguard Worker int net_error, 196*6777b538SAndroid Build Coastguard Worker const SSLInfo& ssl_info, 197*6777b538SAndroid Build Coastguard Worker bool fatal); 198*6777b538SAndroid Build Coastguard Worker 199*6777b538SAndroid Build Coastguard Worker // After calling Start(), the delegate will receive an OnResponseStarted 200*6777b538SAndroid Build Coastguard Worker // callback when the request has completed. |net_error| will be set to OK 201*6777b538SAndroid Build Coastguard Worker // or an actual net error. On success, all redirects have been 202*6777b538SAndroid Build Coastguard Worker // followed and the final response is beginning to arrive. At this point, 203*6777b538SAndroid Build Coastguard Worker // meta data about the response is available, including for example HTTP 204*6777b538SAndroid Build Coastguard Worker // response headers if this is a request for a HTTP resource. 205*6777b538SAndroid Build Coastguard Worker virtual void OnResponseStarted(URLRequest* request, int net_error); 206*6777b538SAndroid Build Coastguard Worker 207*6777b538SAndroid Build Coastguard Worker // Called when the a Read of the response body is completed after an 208*6777b538SAndroid Build Coastguard Worker // IO_PENDING status from a Read() call. 209*6777b538SAndroid Build Coastguard Worker // The data read is filled into the buffer which the caller passed 210*6777b538SAndroid Build Coastguard Worker // to Read() previously. 211*6777b538SAndroid Build Coastguard Worker // 212*6777b538SAndroid Build Coastguard Worker // If an error occurred, |bytes_read| will be set to the error. 213*6777b538SAndroid Build Coastguard Worker virtual void OnReadCompleted(URLRequest* request, int bytes_read) = 0; 214*6777b538SAndroid Build Coastguard Worker 215*6777b538SAndroid Build Coastguard Worker protected: 216*6777b538SAndroid Build Coastguard Worker virtual ~Delegate() = default; 217*6777b538SAndroid Build Coastguard Worker }; 218*6777b538SAndroid Build Coastguard Worker 219*6777b538SAndroid Build Coastguard Worker // URLRequests are always created by calling URLRequestContext::CreateRequest. 220*6777b538SAndroid Build Coastguard Worker URLRequest(base::PassKey<URLRequestContext> pass_key, 221*6777b538SAndroid Build Coastguard Worker const GURL& url, 222*6777b538SAndroid Build Coastguard Worker RequestPriority priority, 223*6777b538SAndroid Build Coastguard Worker Delegate* delegate, 224*6777b538SAndroid Build Coastguard Worker const URLRequestContext* context, 225*6777b538SAndroid Build Coastguard Worker NetworkTrafficAnnotationTag traffic_annotation, 226*6777b538SAndroid Build Coastguard Worker bool is_for_websockets, 227*6777b538SAndroid Build Coastguard Worker std::optional<net::NetLogSource> net_log_source); 228*6777b538SAndroid Build Coastguard Worker 229*6777b538SAndroid Build Coastguard Worker URLRequest(const URLRequest&) = delete; 230*6777b538SAndroid Build Coastguard Worker URLRequest& operator=(const URLRequest&) = delete; 231*6777b538SAndroid Build Coastguard Worker 232*6777b538SAndroid Build Coastguard Worker // If destroyed after Start() has been called but while IO is pending, 233*6777b538SAndroid Build Coastguard Worker // then the request will be effectively canceled and the delegate 234*6777b538SAndroid Build Coastguard Worker // will not have any more of its methods called. 235*6777b538SAndroid Build Coastguard Worker ~URLRequest() override; 236*6777b538SAndroid Build Coastguard Worker 237*6777b538SAndroid Build Coastguard Worker // Changes the default cookie policy from allowing all cookies to blocking all 238*6777b538SAndroid Build Coastguard Worker // cookies. Embedders that want to implement a more flexible policy should 239*6777b538SAndroid Build Coastguard Worker // change the default to blocking all cookies, and provide a NetworkDelegate 240*6777b538SAndroid Build Coastguard Worker // with the URLRequestContext that maintains the CookieStore. 241*6777b538SAndroid Build Coastguard Worker // The cookie policy default has to be set before the first URLRequest is 242*6777b538SAndroid Build Coastguard Worker // started. Once it was set to block all cookies, it cannot be changed back. 243*6777b538SAndroid Build Coastguard Worker static void SetDefaultCookiePolicyToBlock(); 244*6777b538SAndroid Build Coastguard Worker 245*6777b538SAndroid Build Coastguard Worker // The original url is the url used to initialize the request, and it may 246*6777b538SAndroid Build Coastguard Worker // differ from the url if the request was redirected. original_url()247*6777b538SAndroid Build Coastguard Worker const GURL& original_url() const { return url_chain_.front(); } 248*6777b538SAndroid Build Coastguard Worker // The chain of urls traversed by this request. If the request had no 249*6777b538SAndroid Build Coastguard Worker // redirects, this vector will contain one element. url_chain()250*6777b538SAndroid Build Coastguard Worker const std::vector<GURL>& url_chain() const { return url_chain_; } url()251*6777b538SAndroid Build Coastguard Worker const GURL& url() const { return url_chain_.back(); } 252*6777b538SAndroid Build Coastguard Worker 253*6777b538SAndroid Build Coastguard Worker // Explicitly set the URL chain for this request. This can be used to 254*6777b538SAndroid Build Coastguard Worker // indicate a chain of redirects that happen at a layer above the network 255*6777b538SAndroid Build Coastguard Worker // service; e.g. navigation redirects. 256*6777b538SAndroid Build Coastguard Worker // 257*6777b538SAndroid Build Coastguard Worker // Note, the last entry in the new `url_chain` will be ignored. Instead 258*6777b538SAndroid Build Coastguard Worker // the request will preserve its current URL. This is done since the higher 259*6777b538SAndroid Build Coastguard Worker // layer providing the explicit `url_chain` may not be aware of modifications 260*6777b538SAndroid Build Coastguard Worker // to the request URL by throttles. 261*6777b538SAndroid Build Coastguard Worker // 262*6777b538SAndroid Build Coastguard Worker // This method should only be called on new requests that have a single 263*6777b538SAndroid Build Coastguard Worker // entry in their existing `url_chain_`. 264*6777b538SAndroid Build Coastguard Worker void SetURLChain(const std::vector<GURL>& url_chain); 265*6777b538SAndroid Build Coastguard Worker 266*6777b538SAndroid Build Coastguard Worker // The URL that should be consulted for the third-party cookie blocking 267*6777b538SAndroid Build Coastguard Worker // policy, as defined in Section 2.1.1 and 2.1.2 of 268*6777b538SAndroid Build Coastguard Worker // https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site. 269*6777b538SAndroid Build Coastguard Worker // 270*6777b538SAndroid Build Coastguard Worker // WARNING: This URL must only be used for the third-party cookie blocking 271*6777b538SAndroid Build Coastguard Worker // policy. It MUST NEVER be used for any kind of SECURITY check. 272*6777b538SAndroid Build Coastguard Worker // 273*6777b538SAndroid Build Coastguard Worker // For example, if a top-level navigation is redirected, the 274*6777b538SAndroid Build Coastguard Worker // first-party for cookies will be the URL of the first URL in the 275*6777b538SAndroid Build Coastguard Worker // redirect chain throughout the whole redirect. If it was used for 276*6777b538SAndroid Build Coastguard Worker // a security check, an attacker might try to get around this check 277*6777b538SAndroid Build Coastguard Worker // by starting from some page that redirects to the 278*6777b538SAndroid Build Coastguard Worker // host-to-be-attacked. 279*6777b538SAndroid Build Coastguard Worker // site_for_cookies()280*6777b538SAndroid Build Coastguard Worker const SiteForCookies& site_for_cookies() const { return site_for_cookies_; } 281*6777b538SAndroid Build Coastguard Worker // This method may only be called before Start(). 282*6777b538SAndroid Build Coastguard Worker void set_site_for_cookies(const SiteForCookies& site_for_cookies); 283*6777b538SAndroid Build Coastguard Worker 284*6777b538SAndroid Build Coastguard Worker // Sets IsolationInfo for the request, which affects whether SameSite cookies 285*6777b538SAndroid Build Coastguard Worker // are sent, what NetworkAnonymizationKey is used for cached resources, and 286*6777b538SAndroid Build Coastguard Worker // how that behavior changes when following redirects. This may only be 287*6777b538SAndroid Build Coastguard Worker // changed before Start() is called. 288*6777b538SAndroid Build Coastguard Worker // 289*6777b538SAndroid Build Coastguard Worker // TODO(https://crbug.com/1060631): This isn't actually used yet for SameSite 290*6777b538SAndroid Build Coastguard Worker // cookies. Update consumers and fix that. set_isolation_info(const IsolationInfo & isolation_info)291*6777b538SAndroid Build Coastguard Worker void set_isolation_info(const IsolationInfo& isolation_info) { 292*6777b538SAndroid Build Coastguard Worker isolation_info_ = isolation_info; 293*6777b538SAndroid Build Coastguard Worker cookie_partition_key_ = CookiePartitionKey::FromNetworkIsolationKey( 294*6777b538SAndroid Build Coastguard Worker isolation_info.network_isolation_key(), 295*6777b538SAndroid Build Coastguard Worker isolation_info_.site_for_cookies(), net::SchemefulSite(original_url())); 296*6777b538SAndroid Build Coastguard Worker } 297*6777b538SAndroid Build Coastguard Worker 298*6777b538SAndroid Build Coastguard Worker // This will convert the passed NetworkAnonymizationKey to an IsolationInfo. 299*6777b538SAndroid Build Coastguard Worker // This IsolationInfo mmay be assigned an inaccurate frame origin because the 300*6777b538SAndroid Build Coastguard Worker // NetworkAnonymizationKey might not contain all the information to populate 301*6777b538SAndroid Build Coastguard Worker // it. Additionally the NetworkAnonymizationKey uses sites which will be 302*6777b538SAndroid Build Coastguard Worker // converted to origins when set on the IsolationInfo. If using this method it 303*6777b538SAndroid Build Coastguard Worker // is required to skip the cache and not use credentials. Before starting the 304*6777b538SAndroid Build Coastguard Worker // request, it must have the LoadFlag LOAD_DISABLE_CACHE set, and must be set 305*6777b538SAndroid Build Coastguard Worker // to not allow credentials, to ensure that the inaccurate frame origin has no 306*6777b538SAndroid Build Coastguard Worker // impact. The request will DCHECK otherwise. 307*6777b538SAndroid Build Coastguard Worker void set_isolation_info_from_network_anonymization_key( 308*6777b538SAndroid Build Coastguard Worker const NetworkAnonymizationKey& network_anonymization_key); 309*6777b538SAndroid Build Coastguard Worker isolation_info()310*6777b538SAndroid Build Coastguard Worker const IsolationInfo& isolation_info() const { return isolation_info_; } 311*6777b538SAndroid Build Coastguard Worker cookie_partition_key()312*6777b538SAndroid Build Coastguard Worker const std::optional<CookiePartitionKey>& cookie_partition_key() const { 313*6777b538SAndroid Build Coastguard Worker return cookie_partition_key_; 314*6777b538SAndroid Build Coastguard Worker } 315*6777b538SAndroid Build Coastguard Worker 316*6777b538SAndroid Build Coastguard Worker // Indicate whether SameSite cookies should be attached even though the 317*6777b538SAndroid Build Coastguard Worker // request is cross-site. force_ignore_site_for_cookies()318*6777b538SAndroid Build Coastguard Worker bool force_ignore_site_for_cookies() const { 319*6777b538SAndroid Build Coastguard Worker return force_ignore_site_for_cookies_; 320*6777b538SAndroid Build Coastguard Worker } set_force_ignore_site_for_cookies(bool attach)321*6777b538SAndroid Build Coastguard Worker void set_force_ignore_site_for_cookies(bool attach) { 322*6777b538SAndroid Build Coastguard Worker force_ignore_site_for_cookies_ = attach; 323*6777b538SAndroid Build Coastguard Worker } 324*6777b538SAndroid Build Coastguard Worker 325*6777b538SAndroid Build Coastguard Worker // Indicates if the request should be treated as a main frame navigation for 326*6777b538SAndroid Build Coastguard Worker // SameSite cookie computations. This flag overrides the IsolationInfo 327*6777b538SAndroid Build Coastguard Worker // request type associated with fetches from a service worker context. force_main_frame_for_same_site_cookies()328*6777b538SAndroid Build Coastguard Worker bool force_main_frame_for_same_site_cookies() const { 329*6777b538SAndroid Build Coastguard Worker return force_main_frame_for_same_site_cookies_; 330*6777b538SAndroid Build Coastguard Worker } set_force_main_frame_for_same_site_cookies(bool value)331*6777b538SAndroid Build Coastguard Worker void set_force_main_frame_for_same_site_cookies(bool value) { 332*6777b538SAndroid Build Coastguard Worker force_main_frame_for_same_site_cookies_ = value; 333*6777b538SAndroid Build Coastguard Worker } 334*6777b538SAndroid Build Coastguard Worker 335*6777b538SAndroid Build Coastguard Worker // Overrides pertaining to cookie settings for this particular request. cookie_setting_overrides()336*6777b538SAndroid Build Coastguard Worker CookieSettingOverrides& cookie_setting_overrides() { 337*6777b538SAndroid Build Coastguard Worker return cookie_setting_overrides_; 338*6777b538SAndroid Build Coastguard Worker } cookie_setting_overrides()339*6777b538SAndroid Build Coastguard Worker const CookieSettingOverrides& cookie_setting_overrides() const { 340*6777b538SAndroid Build Coastguard Worker return cookie_setting_overrides_; 341*6777b538SAndroid Build Coastguard Worker } 342*6777b538SAndroid Build Coastguard Worker 343*6777b538SAndroid Build Coastguard Worker // The first-party URL policy to apply when updating the first party URL 344*6777b538SAndroid Build Coastguard Worker // during redirects. The first-party URL policy may only be changed before 345*6777b538SAndroid Build Coastguard Worker // Start() is called. first_party_url_policy()346*6777b538SAndroid Build Coastguard Worker RedirectInfo::FirstPartyURLPolicy first_party_url_policy() const { 347*6777b538SAndroid Build Coastguard Worker return first_party_url_policy_; 348*6777b538SAndroid Build Coastguard Worker } 349*6777b538SAndroid Build Coastguard Worker void set_first_party_url_policy( 350*6777b538SAndroid Build Coastguard Worker RedirectInfo::FirstPartyURLPolicy first_party_url_policy); 351*6777b538SAndroid Build Coastguard Worker 352*6777b538SAndroid Build Coastguard Worker // The origin of the context which initiated the request. This is distinct 353*6777b538SAndroid Build Coastguard Worker // from the "first party for cookies" discussed above in a number of ways: 354*6777b538SAndroid Build Coastguard Worker // 355*6777b538SAndroid Build Coastguard Worker // 1. The request's initiator does not change during a redirect. If a form 356*6777b538SAndroid Build Coastguard Worker // submission from `https://example.com/` redirects through a number of 357*6777b538SAndroid Build Coastguard Worker // sites before landing on `https://not-example.com/`, the initiator for 358*6777b538SAndroid Build Coastguard Worker // each of those requests will be `https://example.com/`. 359*6777b538SAndroid Build Coastguard Worker // 360*6777b538SAndroid Build Coastguard Worker // 2. The request's initiator is the origin of the frame or worker which made 361*6777b538SAndroid Build Coastguard Worker // the request, even for top-level navigations. That is, if 362*6777b538SAndroid Build Coastguard Worker // `https://example.com/`'s form submission is made in the top-level frame, 363*6777b538SAndroid Build Coastguard Worker // the first party for cookies would be the target URL's origin. The 364*6777b538SAndroid Build Coastguard Worker // initiator remains `https://example.com/`. 365*6777b538SAndroid Build Coastguard Worker // 366*6777b538SAndroid Build Coastguard Worker // This value is used to perform the cross-origin check specified in Section 367*6777b538SAndroid Build Coastguard Worker // 4.3 of https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site. 368*6777b538SAndroid Build Coastguard Worker // 369*6777b538SAndroid Build Coastguard Worker // Note: the initiator can be null for browser-initiated top level 370*6777b538SAndroid Build Coastguard Worker // navigations. This is different from a unique Origin (e.g. in sandboxed 371*6777b538SAndroid Build Coastguard Worker // iframes). initiator()372*6777b538SAndroid Build Coastguard Worker const std::optional<url::Origin>& initiator() const { return initiator_; } 373*6777b538SAndroid Build Coastguard Worker // This method may only be called before Start(). 374*6777b538SAndroid Build Coastguard Worker void set_initiator(const std::optional<url::Origin>& initiator); 375*6777b538SAndroid Build Coastguard Worker 376*6777b538SAndroid Build Coastguard Worker // The request method. "GET" is the default value. The request method may 377*6777b538SAndroid Build Coastguard Worker // only be changed before Start() is called. Request methods are 378*6777b538SAndroid Build Coastguard Worker // case-sensitive, so standard HTTP methods like GET or POST should be 379*6777b538SAndroid Build Coastguard Worker // specified in uppercase. method()380*6777b538SAndroid Build Coastguard Worker const std::string& method() const { return method_; } 381*6777b538SAndroid Build Coastguard Worker void set_method(std::string_view method); 382*6777b538SAndroid Build Coastguard Worker 383*6777b538SAndroid Build Coastguard Worker #if BUILDFLAG(ENABLE_REPORTING) 384*6777b538SAndroid Build Coastguard Worker // Reporting upload nesting depth of this request. 385*6777b538SAndroid Build Coastguard Worker // 386*6777b538SAndroid Build Coastguard Worker // If the request is not a Reporting upload, the depth is 0. 387*6777b538SAndroid Build Coastguard Worker // 388*6777b538SAndroid Build Coastguard Worker // If the request is a Reporting upload, the depth is the max of the depth 389*6777b538SAndroid Build Coastguard Worker // of the requests reported within it plus 1. (Non-NEL reports are 390*6777b538SAndroid Build Coastguard Worker // considered to have depth 0.) reporting_upload_depth()391*6777b538SAndroid Build Coastguard Worker int reporting_upload_depth() const { return reporting_upload_depth_; } 392*6777b538SAndroid Build Coastguard Worker void set_reporting_upload_depth(int reporting_upload_depth); 393*6777b538SAndroid Build Coastguard Worker #endif 394*6777b538SAndroid Build Coastguard Worker 395*6777b538SAndroid Build Coastguard Worker // The referrer URL for the request referrer()396*6777b538SAndroid Build Coastguard Worker const std::string& referrer() const { return referrer_; } 397*6777b538SAndroid Build Coastguard Worker // Sets the referrer URL for the request. Can only be changed before Start() 398*6777b538SAndroid Build Coastguard Worker // is called. |referrer| is sanitized to remove URL fragment, user name and 399*6777b538SAndroid Build Coastguard Worker // password. If a referrer policy is set via set_referrer_policy(), then 400*6777b538SAndroid Build Coastguard Worker // |referrer| should obey the policy; if it doesn't, it will be cleared when 401*6777b538SAndroid Build Coastguard Worker // the request is started. The referrer URL may be suppressed or changed 402*6777b538SAndroid Build Coastguard Worker // during the course of the request, for example because of a referrer policy 403*6777b538SAndroid Build Coastguard Worker // set with set_referrer_policy(). 404*6777b538SAndroid Build Coastguard Worker void SetReferrer(std::string_view referrer); 405*6777b538SAndroid Build Coastguard Worker 406*6777b538SAndroid Build Coastguard Worker // The referrer policy to apply when updating the referrer during redirects. 407*6777b538SAndroid Build Coastguard Worker // The referrer policy may only be changed before Start() is called. Any 408*6777b538SAndroid Build Coastguard Worker // referrer set via SetReferrer() is expected to obey the policy set via 409*6777b538SAndroid Build Coastguard Worker // set_referrer_policy(); otherwise the referrer will be cleared when the 410*6777b538SAndroid Build Coastguard Worker // request is started. referrer_policy()411*6777b538SAndroid Build Coastguard Worker ReferrerPolicy referrer_policy() const { return referrer_policy_; } 412*6777b538SAndroid Build Coastguard Worker void set_referrer_policy(ReferrerPolicy referrer_policy); 413*6777b538SAndroid Build Coastguard Worker 414*6777b538SAndroid Build Coastguard Worker // Sets whether credentials are allowed. 415*6777b538SAndroid Build Coastguard Worker // If credentials are allowed, the request will send and save HTTP 416*6777b538SAndroid Build Coastguard Worker // cookies, as well as authentication to the origin server. If not, 417*6777b538SAndroid Build Coastguard Worker // they will not be sent, however proxy-level authentication will 418*6777b538SAndroid Build Coastguard Worker // still occur. Setting this will force the LOAD_DO_NOT_SAVE_COOKIES field to 419*6777b538SAndroid Build Coastguard Worker // be set in |load_flags_|. See https://crbug.com/799935. 420*6777b538SAndroid Build Coastguard Worker void set_allow_credentials(bool allow_credentials); allow_credentials()421*6777b538SAndroid Build Coastguard Worker bool allow_credentials() const { return allow_credentials_; } 422*6777b538SAndroid Build Coastguard Worker 423*6777b538SAndroid Build Coastguard Worker // Sets the upload data. 424*6777b538SAndroid Build Coastguard Worker void set_upload(std::unique_ptr<UploadDataStream> upload); 425*6777b538SAndroid Build Coastguard Worker 426*6777b538SAndroid Build Coastguard Worker // Gets the upload data. 427*6777b538SAndroid Build Coastguard Worker const UploadDataStream* get_upload_for_testing() const; 428*6777b538SAndroid Build Coastguard Worker 429*6777b538SAndroid Build Coastguard Worker // Returns true if the request has a non-empty message body to upload. 430*6777b538SAndroid Build Coastguard Worker bool has_upload() const; 431*6777b538SAndroid Build Coastguard Worker 432*6777b538SAndroid Build Coastguard Worker // Set or remove a extra request header. These methods may only be called 433*6777b538SAndroid Build Coastguard Worker // before Start() is called, or between receiving a redirect and trying to 434*6777b538SAndroid Build Coastguard Worker // follow it. 435*6777b538SAndroid Build Coastguard Worker void SetExtraRequestHeaderByName(std::string_view name, 436*6777b538SAndroid Build Coastguard Worker std::string_view value, 437*6777b538SAndroid Build Coastguard Worker bool overwrite); 438*6777b538SAndroid Build Coastguard Worker void RemoveRequestHeaderByName(std::string_view name); 439*6777b538SAndroid Build Coastguard Worker 440*6777b538SAndroid Build Coastguard Worker // Sets all extra request headers. Any extra request headers set by other 441*6777b538SAndroid Build Coastguard Worker // methods are overwritten by this method. This method may only be called 442*6777b538SAndroid Build Coastguard Worker // before Start() is called. It is an error to call it later. 443*6777b538SAndroid Build Coastguard Worker void SetExtraRequestHeaders(const HttpRequestHeaders& headers); 444*6777b538SAndroid Build Coastguard Worker extra_request_headers()445*6777b538SAndroid Build Coastguard Worker const HttpRequestHeaders& extra_request_headers() const { 446*6777b538SAndroid Build Coastguard Worker return extra_request_headers_; 447*6777b538SAndroid Build Coastguard Worker } 448*6777b538SAndroid Build Coastguard Worker 449*6777b538SAndroid Build Coastguard Worker // Gets the total amount of data received from network after SSL decoding and 450*6777b538SAndroid Build Coastguard Worker // proxy handling. Pertains only to the last URLRequestJob issued by this 451*6777b538SAndroid Build Coastguard Worker // URLRequest, i.e. reset on redirects, but not reset when multiple roundtrips 452*6777b538SAndroid Build Coastguard Worker // are used for range requests or auth. 453*6777b538SAndroid Build Coastguard Worker int64_t GetTotalReceivedBytes() const; 454*6777b538SAndroid Build Coastguard Worker 455*6777b538SAndroid Build Coastguard Worker // Gets the total amount of data sent over the network before SSL encoding and 456*6777b538SAndroid Build Coastguard Worker // proxy handling. Pertains only to the last URLRequestJob issued by this 457*6777b538SAndroid Build Coastguard Worker // URLRequest, i.e. reset on redirects, but not reset when multiple roundtrips 458*6777b538SAndroid Build Coastguard Worker // are used for range requests or auth. 459*6777b538SAndroid Build Coastguard Worker int64_t GetTotalSentBytes() const; 460*6777b538SAndroid Build Coastguard Worker 461*6777b538SAndroid Build Coastguard Worker // The size of the response body before removing any content encodings. 462*6777b538SAndroid Build Coastguard Worker // Does not include redirects or sub-requests issued at lower levels (range 463*6777b538SAndroid Build Coastguard Worker // requests or auth). Only includes bytes which have been read so far, 464*6777b538SAndroid Build Coastguard Worker // including bytes from the cache. 465*6777b538SAndroid Build Coastguard Worker int64_t GetRawBodyBytes() const; 466*6777b538SAndroid Build Coastguard Worker 467*6777b538SAndroid Build Coastguard Worker // Returns the current load state for the request. The returned value's 468*6777b538SAndroid Build Coastguard Worker // |param| field is an optional parameter describing details related to the 469*6777b538SAndroid Build Coastguard Worker // load state. Not all load states have a parameter. 470*6777b538SAndroid Build Coastguard Worker LoadStateWithParam GetLoadState() const; 471*6777b538SAndroid Build Coastguard Worker 472*6777b538SAndroid Build Coastguard Worker // Returns a partial representation of the request's state as a value, for 473*6777b538SAndroid Build Coastguard Worker // debugging. 474*6777b538SAndroid Build Coastguard Worker base::Value::Dict GetStateAsValue() const; 475*6777b538SAndroid Build Coastguard Worker 476*6777b538SAndroid Build Coastguard Worker // Logs information about the what external object currently blocking the 477*6777b538SAndroid Build Coastguard Worker // request. LogUnblocked must be called before resuming the request. This 478*6777b538SAndroid Build Coastguard Worker // can be called multiple times in a row either with or without calling 479*6777b538SAndroid Build Coastguard Worker // LogUnblocked between calls. |blocked_by| must not be empty. 480*6777b538SAndroid Build Coastguard Worker void LogBlockedBy(std::string_view blocked_by); 481*6777b538SAndroid Build Coastguard Worker 482*6777b538SAndroid Build Coastguard Worker // Just like LogBlockedBy, but also makes GetLoadState return source as the 483*6777b538SAndroid Build Coastguard Worker // |param| in the value returned by GetLoadState. Calling LogUnblocked or 484*6777b538SAndroid Build Coastguard Worker // LogBlockedBy will clear the load param. |blocked_by| must not be empty. 485*6777b538SAndroid Build Coastguard Worker void LogAndReportBlockedBy(std::string_view blocked_by); 486*6777b538SAndroid Build Coastguard Worker 487*6777b538SAndroid Build Coastguard Worker // Logs that the request is no longer blocked by the last caller to 488*6777b538SAndroid Build Coastguard Worker // LogBlockedBy. 489*6777b538SAndroid Build Coastguard Worker void LogUnblocked(); 490*6777b538SAndroid Build Coastguard Worker 491*6777b538SAndroid Build Coastguard Worker // Returns the current upload progress in bytes. When the upload data is 492*6777b538SAndroid Build Coastguard Worker // chunked, size is set to zero, but position will not be. 493*6777b538SAndroid Build Coastguard Worker UploadProgress GetUploadProgress() const; 494*6777b538SAndroid Build Coastguard Worker 495*6777b538SAndroid Build Coastguard Worker // Get response header(s) by name. This method may only be called 496*6777b538SAndroid Build Coastguard Worker // once the delegate's OnResponseStarted method has been called. Headers 497*6777b538SAndroid Build Coastguard Worker // that appear more than once in the response are coalesced, with values 498*6777b538SAndroid Build Coastguard Worker // separated by commas (per RFC 2616). This will not work with cookies since 499*6777b538SAndroid Build Coastguard Worker // comma can be used in cookie values. 500*6777b538SAndroid Build Coastguard Worker void GetResponseHeaderByName(std::string_view name, std::string* value) const; 501*6777b538SAndroid Build Coastguard Worker 502*6777b538SAndroid Build Coastguard Worker // The time when |this| was constructed. creation_time()503*6777b538SAndroid Build Coastguard Worker base::TimeTicks creation_time() const { return creation_time_; } 504*6777b538SAndroid Build Coastguard Worker 505*6777b538SAndroid Build Coastguard Worker // The time at which the returned response was requested. For cached 506*6777b538SAndroid Build Coastguard Worker // responses, this is the last time the cache entry was validated. request_time()507*6777b538SAndroid Build Coastguard Worker const base::Time& request_time() const { return response_info_.request_time; } 508*6777b538SAndroid Build Coastguard Worker 509*6777b538SAndroid Build Coastguard Worker // The time at which the returned response was generated. For cached 510*6777b538SAndroid Build Coastguard Worker // responses, this is the last time the cache entry was validated. response_time()511*6777b538SAndroid Build Coastguard Worker const base::Time& response_time() const { 512*6777b538SAndroid Build Coastguard Worker return response_info_.response_time; 513*6777b538SAndroid Build Coastguard Worker } 514*6777b538SAndroid Build Coastguard Worker 515*6777b538SAndroid Build Coastguard Worker // Indicate if this response was fetched from disk cache. was_cached()516*6777b538SAndroid Build Coastguard Worker bool was_cached() const { return response_info_.was_cached; } 517*6777b538SAndroid Build Coastguard Worker 518*6777b538SAndroid Build Coastguard Worker // Returns true if the URLRequest was delivered over SPDY. was_fetched_via_spdy()519*6777b538SAndroid Build Coastguard Worker bool was_fetched_via_spdy() const { 520*6777b538SAndroid Build Coastguard Worker return response_info_.was_fetched_via_spdy; 521*6777b538SAndroid Build Coastguard Worker } 522*6777b538SAndroid Build Coastguard Worker 523*6777b538SAndroid Build Coastguard Worker // Returns the host and port that the content was fetched from. See 524*6777b538SAndroid Build Coastguard Worker // http_response_info.h for caveats relating to cached content. 525*6777b538SAndroid Build Coastguard Worker IPEndPoint GetResponseRemoteEndpoint() const; 526*6777b538SAndroid Build Coastguard Worker 527*6777b538SAndroid Build Coastguard Worker // Get all response headers, as a HttpResponseHeaders object. See comments 528*6777b538SAndroid Build Coastguard Worker // in HttpResponseHeaders class as to the format of the data. 529*6777b538SAndroid Build Coastguard Worker HttpResponseHeaders* response_headers() const; 530*6777b538SAndroid Build Coastguard Worker 531*6777b538SAndroid Build Coastguard Worker // Get the SSL connection info. ssl_info()532*6777b538SAndroid Build Coastguard Worker const SSLInfo& ssl_info() const { return response_info_.ssl_info; } 533*6777b538SAndroid Build Coastguard Worker 534*6777b538SAndroid Build Coastguard Worker const std::optional<AuthChallengeInfo>& auth_challenge_info() const; 535*6777b538SAndroid Build Coastguard Worker 536*6777b538SAndroid Build Coastguard Worker // Gets timing information related to the request. Events that have not yet 537*6777b538SAndroid Build Coastguard Worker // occurred are left uninitialized. After a second request starts, due to 538*6777b538SAndroid Build Coastguard Worker // a redirect or authentication, values will be reset. 539*6777b538SAndroid Build Coastguard Worker // 540*6777b538SAndroid Build Coastguard Worker // LoadTimingInfo only contains ConnectTiming information and socket IDs for 541*6777b538SAndroid Build Coastguard Worker // non-cached HTTP responses. 542*6777b538SAndroid Build Coastguard Worker void GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const; 543*6777b538SAndroid Build Coastguard Worker 544*6777b538SAndroid Build Coastguard Worker // Gets the networkd error details of the most recent origin that the network 545*6777b538SAndroid Build Coastguard Worker // stack makes the request to. 546*6777b538SAndroid Build Coastguard Worker void PopulateNetErrorDetails(NetErrorDetails* details) const; 547*6777b538SAndroid Build Coastguard Worker 548*6777b538SAndroid Build Coastguard Worker // Gets the remote endpoint of the most recent socket that the network stack 549*6777b538SAndroid Build Coastguard Worker // used to make this request. 550*6777b538SAndroid Build Coastguard Worker // 551*6777b538SAndroid Build Coastguard Worker // Note that GetResponseRemoteEndpoint returns the |socket_address| field from 552*6777b538SAndroid Build Coastguard Worker // HttpResponseInfo, which is only populated once the response headers are 553*6777b538SAndroid Build Coastguard Worker // received, and can return cached values for cache revalidation requests. 554*6777b538SAndroid Build Coastguard Worker // GetTransactionRemoteEndpoint will only return addresses from the current 555*6777b538SAndroid Build Coastguard Worker // request. 556*6777b538SAndroid Build Coastguard Worker // 557*6777b538SAndroid Build Coastguard Worker // Returns true and fills in |endpoint| if the endpoint is available; returns 558*6777b538SAndroid Build Coastguard Worker // false and leaves |endpoint| unchanged if it is unavailable. 559*6777b538SAndroid Build Coastguard Worker bool GetTransactionRemoteEndpoint(IPEndPoint* endpoint) const; 560*6777b538SAndroid Build Coastguard Worker 561*6777b538SAndroid Build Coastguard Worker // Get the mime type. This method may only be called once the delegate's 562*6777b538SAndroid Build Coastguard Worker // OnResponseStarted method has been called. 563*6777b538SAndroid Build Coastguard Worker void GetMimeType(std::string* mime_type) const; 564*6777b538SAndroid Build Coastguard Worker 565*6777b538SAndroid Build Coastguard Worker // Get the charset (character encoding). This method may only be called once 566*6777b538SAndroid Build Coastguard Worker // the delegate's OnResponseStarted method has been called. 567*6777b538SAndroid Build Coastguard Worker void GetCharset(std::string* charset) const; 568*6777b538SAndroid Build Coastguard Worker 569*6777b538SAndroid Build Coastguard Worker // Returns the HTTP response code (e.g., 200, 404, and so on). This method 570*6777b538SAndroid Build Coastguard Worker // may only be called once the delegate's OnResponseStarted method has been 571*6777b538SAndroid Build Coastguard Worker // called. For non-HTTP requests, this method returns -1. 572*6777b538SAndroid Build Coastguard Worker int GetResponseCode() const; 573*6777b538SAndroid Build Coastguard Worker 574*6777b538SAndroid Build Coastguard Worker // Get the HTTP response info in its entirety. response_info()575*6777b538SAndroid Build Coastguard Worker const HttpResponseInfo& response_info() const { return response_info_; } 576*6777b538SAndroid Build Coastguard Worker 577*6777b538SAndroid Build Coastguard Worker // Access the LOAD_* flags modifying this request (see load_flags.h). load_flags()578*6777b538SAndroid Build Coastguard Worker int load_flags() const { return load_flags_; } 579*6777b538SAndroid Build Coastguard Worker is_created_from_network_anonymization_key()580*6777b538SAndroid Build Coastguard Worker bool is_created_from_network_anonymization_key() const { 581*6777b538SAndroid Build Coastguard Worker return is_created_from_network_anonymization_key_; 582*6777b538SAndroid Build Coastguard Worker } 583*6777b538SAndroid Build Coastguard Worker 584*6777b538SAndroid Build Coastguard Worker // Returns the Secure DNS Policy for the request. secure_dns_policy()585*6777b538SAndroid Build Coastguard Worker SecureDnsPolicy secure_dns_policy() const { return secure_dns_policy_; } 586*6777b538SAndroid Build Coastguard Worker 587*6777b538SAndroid Build Coastguard Worker void set_maybe_sent_cookies(CookieAccessResultList cookies); 588*6777b538SAndroid Build Coastguard Worker void set_maybe_stored_cookies(CookieAndLineAccessResultList cookies); 589*6777b538SAndroid Build Coastguard Worker 590*6777b538SAndroid Build Coastguard Worker // These lists contain a list of cookies that are associated with the given 591*6777b538SAndroid Build Coastguard Worker // request, both those that were sent and accepted, and those that were 592*6777b538SAndroid Build Coastguard Worker // removed or flagged from the request before use. The status indicates 593*6777b538SAndroid Build Coastguard Worker // whether they were actually used (INCLUDE), or the reason they were removed 594*6777b538SAndroid Build Coastguard Worker // or flagged. They are cleared on redirects and other request restarts that 595*6777b538SAndroid Build Coastguard Worker // cause sent cookies to be recomputed / new cookies to potentially be 596*6777b538SAndroid Build Coastguard Worker // received (such as calling SetAuth() to send HTTP auth credentials, but not 597*6777b538SAndroid Build Coastguard Worker // calling ContinueWithCertification() to respond to client cert challenges), 598*6777b538SAndroid Build Coastguard Worker // and only contain the cookies relevant to the most recent roundtrip. 599*6777b538SAndroid Build Coastguard Worker 600*6777b538SAndroid Build Coastguard Worker // Populated while the http request is being built. maybe_sent_cookies()601*6777b538SAndroid Build Coastguard Worker const CookieAccessResultList& maybe_sent_cookies() const { 602*6777b538SAndroid Build Coastguard Worker return maybe_sent_cookies_; 603*6777b538SAndroid Build Coastguard Worker } 604*6777b538SAndroid Build Coastguard Worker // Populated after the response headers are received. maybe_stored_cookies()605*6777b538SAndroid Build Coastguard Worker const CookieAndLineAccessResultList& maybe_stored_cookies() const { 606*6777b538SAndroid Build Coastguard Worker return maybe_stored_cookies_; 607*6777b538SAndroid Build Coastguard Worker } 608*6777b538SAndroid Build Coastguard Worker 609*6777b538SAndroid Build Coastguard Worker // The new flags may change the IGNORE_LIMITS flag only when called 610*6777b538SAndroid Build Coastguard Worker // before Start() is called, it must only set the flag, and if set, 611*6777b538SAndroid Build Coastguard Worker // the priority of this request must already be MAXIMUM_PRIORITY. 612*6777b538SAndroid Build Coastguard Worker void SetLoadFlags(int flags); 613*6777b538SAndroid Build Coastguard Worker 614*6777b538SAndroid Build Coastguard Worker // Controls the Secure DNS behavior to use when creating the socket for this 615*6777b538SAndroid Build Coastguard Worker // request. 616*6777b538SAndroid Build Coastguard Worker void SetSecureDnsPolicy(SecureDnsPolicy secure_dns_policy); 617*6777b538SAndroid Build Coastguard Worker 618*6777b538SAndroid Build Coastguard Worker // Returns true if the request is "pending" (i.e., if Start() has been called, 619*6777b538SAndroid Build Coastguard Worker // and the response has not yet been called). is_pending()620*6777b538SAndroid Build Coastguard Worker bool is_pending() const { return is_pending_; } 621*6777b538SAndroid Build Coastguard Worker 622*6777b538SAndroid Build Coastguard Worker // Returns true if the request is in the process of redirecting to a new 623*6777b538SAndroid Build Coastguard Worker // URL but has not yet initiated the new request. is_redirecting()624*6777b538SAndroid Build Coastguard Worker bool is_redirecting() const { return is_redirecting_; } 625*6777b538SAndroid Build Coastguard Worker 626*6777b538SAndroid Build Coastguard Worker // This method is called to start the request. The delegate will receive 627*6777b538SAndroid Build Coastguard Worker // a OnResponseStarted callback when the request is started. The request 628*6777b538SAndroid Build Coastguard Worker // must have a delegate set before this method is called. 629*6777b538SAndroid Build Coastguard Worker void Start(); 630*6777b538SAndroid Build Coastguard Worker 631*6777b538SAndroid Build Coastguard Worker // This method may be called at any time after Start() has been called to 632*6777b538SAndroid Build Coastguard Worker // cancel the request. This method may be called many times, and it has 633*6777b538SAndroid Build Coastguard Worker // no effect once the response has completed. It is guaranteed that no 634*6777b538SAndroid Build Coastguard Worker // methods of the delegate will be called after the request has been 635*6777b538SAndroid Build Coastguard Worker // cancelled, except that this may call the delegate's OnReadCompleted() 636*6777b538SAndroid Build Coastguard Worker // during the call to Cancel itself. Returns |ERR_ABORTED| or other net error 637*6777b538SAndroid Build Coastguard Worker // if there was one. 638*6777b538SAndroid Build Coastguard Worker int Cancel(); 639*6777b538SAndroid Build Coastguard Worker 640*6777b538SAndroid Build Coastguard Worker // Cancels the request and sets the error to |error|, unless the request 641*6777b538SAndroid Build Coastguard Worker // already failed with another error code (see net_error_list.h). Returns 642*6777b538SAndroid Build Coastguard Worker // final network error code. 643*6777b538SAndroid Build Coastguard Worker int CancelWithError(int error); 644*6777b538SAndroid Build Coastguard Worker 645*6777b538SAndroid Build Coastguard Worker // Cancels the request and sets the error to |error| (see net_error_list.h 646*6777b538SAndroid Build Coastguard Worker // for values) and attaches |ssl_info| as the SSLInfo for that request. This 647*6777b538SAndroid Build Coastguard Worker // is useful to attach a certificate and certificate error to a canceled 648*6777b538SAndroid Build Coastguard Worker // request. 649*6777b538SAndroid Build Coastguard Worker void CancelWithSSLError(int error, const SSLInfo& ssl_info); 650*6777b538SAndroid Build Coastguard Worker 651*6777b538SAndroid Build Coastguard Worker // Read initiates an asynchronous read from the response, and must only be 652*6777b538SAndroid Build Coastguard Worker // called after the OnResponseStarted callback is received with a net::OK. If 653*6777b538SAndroid Build Coastguard Worker // data is available, length and the data will be returned immediately. If the 654*6777b538SAndroid Build Coastguard Worker // request has failed, an error code will be returned. If data is not yet 655*6777b538SAndroid Build Coastguard Worker // available, Read returns net::ERR_IO_PENDING, and the Delegate's 656*6777b538SAndroid Build Coastguard Worker // OnReadComplete method will be called asynchronously with the result of the 657*6777b538SAndroid Build Coastguard Worker // read, unless the URLRequest is canceled. 658*6777b538SAndroid Build Coastguard Worker // 659*6777b538SAndroid Build Coastguard Worker // The |buf| parameter is a buffer to receive the data. If the operation 660*6777b538SAndroid Build Coastguard Worker // completes asynchronously, the implementation will reference the buffer 661*6777b538SAndroid Build Coastguard Worker // until OnReadComplete is called. The buffer must be at least |max_bytes| in 662*6777b538SAndroid Build Coastguard Worker // length. 663*6777b538SAndroid Build Coastguard Worker // 664*6777b538SAndroid Build Coastguard Worker // The |max_bytes| parameter is the maximum number of bytes to read. 665*6777b538SAndroid Build Coastguard Worker int Read(IOBuffer* buf, int max_bytes); 666*6777b538SAndroid Build Coastguard Worker 667*6777b538SAndroid Build Coastguard Worker // This method may be called to follow a redirect that was deferred in 668*6777b538SAndroid Build Coastguard Worker // response to an OnReceivedRedirect call. If non-null, 669*6777b538SAndroid Build Coastguard Worker // |modified_headers| are changes applied to the request headers after 670*6777b538SAndroid Build Coastguard Worker // updating them for the redirect. 671*6777b538SAndroid Build Coastguard Worker void FollowDeferredRedirect( 672*6777b538SAndroid Build Coastguard Worker const std::optional<std::vector<std::string>>& removed_headers, 673*6777b538SAndroid Build Coastguard Worker const std::optional<net::HttpRequestHeaders>& modified_headers); 674*6777b538SAndroid Build Coastguard Worker 675*6777b538SAndroid Build Coastguard Worker // One of the following two methods should be called in response to an 676*6777b538SAndroid Build Coastguard Worker // OnAuthRequired() callback (and only then). 677*6777b538SAndroid Build Coastguard Worker // SetAuth will reissue the request with the given credentials. 678*6777b538SAndroid Build Coastguard Worker // CancelAuth will give up and display the error page. 679*6777b538SAndroid Build Coastguard Worker void SetAuth(const AuthCredentials& credentials); 680*6777b538SAndroid Build Coastguard Worker void CancelAuth(); 681*6777b538SAndroid Build Coastguard Worker 682*6777b538SAndroid Build Coastguard Worker // This method can be called after the user selects a client certificate to 683*6777b538SAndroid Build Coastguard Worker // instruct this URLRequest to continue with the request with the 684*6777b538SAndroid Build Coastguard Worker // certificate. Pass NULL if the user doesn't have a client certificate. 685*6777b538SAndroid Build Coastguard Worker void ContinueWithCertificate(scoped_refptr<X509Certificate> client_cert, 686*6777b538SAndroid Build Coastguard Worker scoped_refptr<SSLPrivateKey> client_private_key); 687*6777b538SAndroid Build Coastguard Worker 688*6777b538SAndroid Build Coastguard Worker // This method can be called after some error notifications to instruct this 689*6777b538SAndroid Build Coastguard Worker // URLRequest to ignore the current error and continue with the request. To 690*6777b538SAndroid Build Coastguard Worker // cancel the request instead, call Cancel(). 691*6777b538SAndroid Build Coastguard Worker void ContinueDespiteLastError(); 692*6777b538SAndroid Build Coastguard Worker 693*6777b538SAndroid Build Coastguard Worker // Aborts the request (without invoking any completion callbacks) and closes 694*6777b538SAndroid Build Coastguard Worker // the current connection, rather than returning it to the socket pool. Only 695*6777b538SAndroid Build Coastguard Worker // affects HTTP/1.1 connections and tunnels. 696*6777b538SAndroid Build Coastguard Worker // 697*6777b538SAndroid Build Coastguard Worker // Intended to be used in cases where socket reuse can potentially leak data 698*6777b538SAndroid Build Coastguard Worker // across sites. 699*6777b538SAndroid Build Coastguard Worker // 700*6777b538SAndroid Build Coastguard Worker // May only be called after Delegate::OnResponseStarted() has been invoked 701*6777b538SAndroid Build Coastguard Worker // with net::OK, but before the body has been completely read. After the last 702*6777b538SAndroid Build Coastguard Worker // body has been read, the socket may have already been handed off to another 703*6777b538SAndroid Build Coastguard Worker // consumer. 704*6777b538SAndroid Build Coastguard Worker // 705*6777b538SAndroid Build Coastguard Worker // Due to transactions potentially being shared by multiple URLRequests in 706*6777b538SAndroid Build Coastguard Worker // some cases, it is possible the socket may not be immediately closed, but 707*6777b538SAndroid Build Coastguard Worker // will instead be closed when all URLRequests sharing the socket have been 708*6777b538SAndroid Build Coastguard Worker // destroyed. 709*6777b538SAndroid Build Coastguard Worker void AbortAndCloseConnection(); 710*6777b538SAndroid Build Coastguard Worker 711*6777b538SAndroid Build Coastguard Worker // Used to specify the context (cookie store, cache) for this request. 712*6777b538SAndroid Build Coastguard Worker const URLRequestContext* context() const; 713*6777b538SAndroid Build Coastguard Worker 714*6777b538SAndroid Build Coastguard Worker // Returns context()->network_delegate(). 715*6777b538SAndroid Build Coastguard Worker NetworkDelegate* network_delegate() const; 716*6777b538SAndroid Build Coastguard Worker net_log()717*6777b538SAndroid Build Coastguard Worker const NetLogWithSource& net_log() const { return net_log_; } 718*6777b538SAndroid Build Coastguard Worker 719*6777b538SAndroid Build Coastguard Worker // Returns the expected content size if available 720*6777b538SAndroid Build Coastguard Worker int64_t GetExpectedContentSize() const; 721*6777b538SAndroid Build Coastguard Worker 722*6777b538SAndroid Build Coastguard Worker // Returns the priority level for this request. priority()723*6777b538SAndroid Build Coastguard Worker RequestPriority priority() const { return priority_; } 724*6777b538SAndroid Build Coastguard Worker 725*6777b538SAndroid Build Coastguard Worker // Returns the incremental loading priority flag for this request. priority_incremental()726*6777b538SAndroid Build Coastguard Worker bool priority_incremental() const { return priority_incremental_; } 727*6777b538SAndroid Build Coastguard Worker 728*6777b538SAndroid Build Coastguard Worker // Sets the priority level for this request and any related 729*6777b538SAndroid Build Coastguard Worker // jobs. Must not change the priority to anything other than 730*6777b538SAndroid Build Coastguard Worker // MAXIMUM_PRIORITY if the IGNORE_LIMITS load flag is set. 731*6777b538SAndroid Build Coastguard Worker void SetPriority(RequestPriority priority); 732*6777b538SAndroid Build Coastguard Worker 733*6777b538SAndroid Build Coastguard Worker // Sets the incremental priority flag for this request. 734*6777b538SAndroid Build Coastguard Worker void SetPriorityIncremental(bool priority_incremental); 735*6777b538SAndroid Build Coastguard Worker set_received_response_content_length(int64_t received_content_length)736*6777b538SAndroid Build Coastguard Worker void set_received_response_content_length(int64_t received_content_length) { 737*6777b538SAndroid Build Coastguard Worker received_response_content_length_ = received_content_length; 738*6777b538SAndroid Build Coastguard Worker } 739*6777b538SAndroid Build Coastguard Worker 740*6777b538SAndroid Build Coastguard Worker // The number of bytes in the raw response body (before any decompression, 741*6777b538SAndroid Build Coastguard Worker // etc.). This is only available after the final Read completes. received_response_content_length()742*6777b538SAndroid Build Coastguard Worker int64_t received_response_content_length() const { 743*6777b538SAndroid Build Coastguard Worker return received_response_content_length_; 744*6777b538SAndroid Build Coastguard Worker } 745*6777b538SAndroid Build Coastguard Worker 746*6777b538SAndroid Build Coastguard Worker // Available when the request headers are sent, which is before the more 747*6777b538SAndroid Build Coastguard Worker // general response_info() is available. proxy_chain()748*6777b538SAndroid Build Coastguard Worker const ProxyChain& proxy_chain() const { return proxy_chain_; } 749*6777b538SAndroid Build Coastguard Worker 750*6777b538SAndroid Build Coastguard Worker // Gets the connection attempts made in the process of servicing this 751*6777b538SAndroid Build Coastguard Worker // URLRequest. Only guaranteed to be valid if called after the request fails 752*6777b538SAndroid Build Coastguard Worker // or after the response headers are received. 753*6777b538SAndroid Build Coastguard Worker ConnectionAttempts GetConnectionAttempts() const; 754*6777b538SAndroid Build Coastguard Worker traffic_annotation()755*6777b538SAndroid Build Coastguard Worker const NetworkTrafficAnnotationTag& traffic_annotation() const { 756*6777b538SAndroid Build Coastguard Worker return traffic_annotation_; 757*6777b538SAndroid Build Coastguard Worker } 758*6777b538SAndroid Build Coastguard Worker 759*6777b538SAndroid Build Coastguard Worker const std::optional<base::flat_set<net::SourceStream::SourceType>>& accepted_stream_types()760*6777b538SAndroid Build Coastguard Worker accepted_stream_types() const { 761*6777b538SAndroid Build Coastguard Worker return accepted_stream_types_; 762*6777b538SAndroid Build Coastguard Worker } 763*6777b538SAndroid Build Coastguard Worker set_accepted_stream_types(const std::optional<base::flat_set<net::SourceStream::SourceType>> & types)764*6777b538SAndroid Build Coastguard Worker void set_accepted_stream_types( 765*6777b538SAndroid Build Coastguard Worker const std::optional<base::flat_set<net::SourceStream::SourceType>>& 766*6777b538SAndroid Build Coastguard Worker types) { 767*6777b538SAndroid Build Coastguard Worker if (types) { 768*6777b538SAndroid Build Coastguard Worker DCHECK(!types->contains(net::SourceStream::SourceType::TYPE_NONE)); 769*6777b538SAndroid Build Coastguard Worker DCHECK(!types->contains(net::SourceStream::SourceType::TYPE_UNKNOWN)); 770*6777b538SAndroid Build Coastguard Worker } 771*6777b538SAndroid Build Coastguard Worker accepted_stream_types_ = types; 772*6777b538SAndroid Build Coastguard Worker } 773*6777b538SAndroid Build Coastguard Worker 774*6777b538SAndroid Build Coastguard Worker // Sets a callback that will be invoked each time the request is about to 775*6777b538SAndroid Build Coastguard Worker // be actually sent and will receive actual request headers that are about 776*6777b538SAndroid Build Coastguard Worker // to hit the wire, including SPDY/QUIC internal headers. 777*6777b538SAndroid Build Coastguard Worker // 778*6777b538SAndroid Build Coastguard Worker // Can only be set once before the request is started. 779*6777b538SAndroid Build Coastguard Worker void SetRequestHeadersCallback(RequestHeadersCallback callback); 780*6777b538SAndroid Build Coastguard Worker 781*6777b538SAndroid Build Coastguard Worker // Sets a callback that will be invoked each time the response is received 782*6777b538SAndroid Build Coastguard Worker // from the remote party with the actual response headers received. Note this 783*6777b538SAndroid Build Coastguard Worker // is different from response_headers() getter in that in case of revalidation 784*6777b538SAndroid Build Coastguard Worker // request, the latter will return cached headers, while the callback will be 785*6777b538SAndroid Build Coastguard Worker // called with a response from the server. 786*6777b538SAndroid Build Coastguard Worker void SetResponseHeadersCallback(ResponseHeadersCallback callback); 787*6777b538SAndroid Build Coastguard Worker 788*6777b538SAndroid Build Coastguard Worker // Sets a callback that will be invoked each time a 103 Early Hints response 789*6777b538SAndroid Build Coastguard Worker // is received from the remote party. 790*6777b538SAndroid Build Coastguard Worker void SetEarlyResponseHeadersCallback(ResponseHeadersCallback callback); 791*6777b538SAndroid Build Coastguard Worker 792*6777b538SAndroid Build Coastguard Worker // Set a callback that will be invoked when a matching shared dictionary is 793*6777b538SAndroid Build Coastguard Worker // available to determine whether it is allowed to use the dictionary. 794*6777b538SAndroid Build Coastguard Worker void SetIsSharedDictionaryReadAllowedCallback( 795*6777b538SAndroid Build Coastguard Worker base::RepeatingCallback<bool()> callback); 796*6777b538SAndroid Build Coastguard Worker 797*6777b538SAndroid Build Coastguard Worker // Sets socket tag to be applied to all sockets used to execute this request. 798*6777b538SAndroid Build Coastguard Worker // Must be set before Start() is called. Only currently supported for HTTP 799*6777b538SAndroid Build Coastguard Worker // and HTTPS requests on Android; UID tagging requires 800*6777b538SAndroid Build Coastguard Worker // MODIFY_NETWORK_ACCOUNTING permission. 801*6777b538SAndroid Build Coastguard Worker // NOTE(pauljensen): Setting a tag disallows sharing of sockets with requests 802*6777b538SAndroid Build Coastguard Worker // with other tags, which may adversely effect performance by prohibiting 803*6777b538SAndroid Build Coastguard Worker // connection sharing. In other words use of multiplexed sockets (e.g. HTTP/2 804*6777b538SAndroid Build Coastguard Worker // and QUIC) will only be allowed if all requests have the same socket tag. 805*6777b538SAndroid Build Coastguard Worker void set_socket_tag(const SocketTag& socket_tag); socket_tag()806*6777b538SAndroid Build Coastguard Worker const SocketTag& socket_tag() const { return socket_tag_; } 807*6777b538SAndroid Build Coastguard Worker 808*6777b538SAndroid Build Coastguard Worker // |upgrade_if_insecure| should be set to true if this request (including 809*6777b538SAndroid Build Coastguard Worker // redirects) should be upgraded to HTTPS due to an Upgrade-Insecure-Requests 810*6777b538SAndroid Build Coastguard Worker // requirement. set_upgrade_if_insecure(bool upgrade_if_insecure)811*6777b538SAndroid Build Coastguard Worker void set_upgrade_if_insecure(bool upgrade_if_insecure) { 812*6777b538SAndroid Build Coastguard Worker upgrade_if_insecure_ = upgrade_if_insecure; 813*6777b538SAndroid Build Coastguard Worker } upgrade_if_insecure()814*6777b538SAndroid Build Coastguard Worker bool upgrade_if_insecure() const { return upgrade_if_insecure_; } 815*6777b538SAndroid Build Coastguard Worker 816*6777b538SAndroid Build Coastguard Worker // `ad_tagged` should be set to true if the request is thought to be related 817*6777b538SAndroid Build Coastguard Worker // to advertising. set_ad_tagged(bool ad_tagged)818*6777b538SAndroid Build Coastguard Worker void set_ad_tagged(bool ad_tagged) { ad_tagged_ = ad_tagged; } ad_tagged()819*6777b538SAndroid Build Coastguard Worker bool ad_tagged() const { return ad_tagged_; } 820*6777b538SAndroid Build Coastguard Worker 821*6777b538SAndroid Build Coastguard Worker // By default, client certs will be sent (provided via 822*6777b538SAndroid Build Coastguard Worker // Delegate::OnCertificateRequested) when cookies are disabled 823*6777b538SAndroid Build Coastguard Worker // (LOAD_DO_NOT_SEND_COOKIES / LOAD_DO_NOT_SAVE_COOKIES). As described at 824*6777b538SAndroid Build Coastguard Worker // https://crbug.com/775438, this is not the desired behavior. When 825*6777b538SAndroid Build Coastguard Worker // |send_client_certs| is set to false, this will suppress the 826*6777b538SAndroid Build Coastguard Worker // Delegate::OnCertificateRequested callback when cookies/credentials are also 827*6777b538SAndroid Build Coastguard Worker // suppressed. This method has no effect if credentials are enabled (cookies 828*6777b538SAndroid Build Coastguard Worker // saved and sent). 829*6777b538SAndroid Build Coastguard Worker // TODO(https://crbug.com/775438): Remove this when the underlying 830*6777b538SAndroid Build Coastguard Worker // issue is fixed. set_send_client_certs(bool send_client_certs)831*6777b538SAndroid Build Coastguard Worker void set_send_client_certs(bool send_client_certs) { 832*6777b538SAndroid Build Coastguard Worker send_client_certs_ = send_client_certs; 833*6777b538SAndroid Build Coastguard Worker } send_client_certs()834*6777b538SAndroid Build Coastguard Worker bool send_client_certs() const { return send_client_certs_; } 835*6777b538SAndroid Build Coastguard Worker is_for_websockets()836*6777b538SAndroid Build Coastguard Worker bool is_for_websockets() const { return is_for_websockets_; } 837*6777b538SAndroid Build Coastguard Worker SetIdempotency(Idempotency idempotency)838*6777b538SAndroid Build Coastguard Worker void SetIdempotency(Idempotency idempotency) { idempotency_ = idempotency; } GetIdempotency()839*6777b538SAndroid Build Coastguard Worker Idempotency GetIdempotency() const { return idempotency_; } 840*6777b538SAndroid Build Coastguard Worker set_has_storage_access(bool has_storage_access)841*6777b538SAndroid Build Coastguard Worker void set_has_storage_access(bool has_storage_access) { 842*6777b538SAndroid Build Coastguard Worker DCHECK(!is_pending_); 843*6777b538SAndroid Build Coastguard Worker DCHECK(!has_notified_completion_); 844*6777b538SAndroid Build Coastguard Worker has_storage_access_ = has_storage_access; 845*6777b538SAndroid Build Coastguard Worker } has_storage_access()846*6777b538SAndroid Build Coastguard Worker bool has_storage_access() const { return has_storage_access_; } 847*6777b538SAndroid Build Coastguard Worker 848*6777b538SAndroid Build Coastguard Worker static bool DefaultCanUseCookies(); 849*6777b538SAndroid Build Coastguard Worker 850*6777b538SAndroid Build Coastguard Worker base::WeakPtr<URLRequest> GetWeakPtr(); 851*6777b538SAndroid Build Coastguard Worker 852*6777b538SAndroid Build Coastguard Worker protected: 853*6777b538SAndroid Build Coastguard Worker // Allow the URLRequestJob class to control the is_pending() flag. set_is_pending(bool value)854*6777b538SAndroid Build Coastguard Worker void set_is_pending(bool value) { is_pending_ = value; } 855*6777b538SAndroid Build Coastguard Worker 856*6777b538SAndroid Build Coastguard Worker // Setter / getter for the status of the request. Status is represented as a 857*6777b538SAndroid Build Coastguard Worker // net::Error code. See |status_|. status()858*6777b538SAndroid Build Coastguard Worker int status() const { return status_; } 859*6777b538SAndroid Build Coastguard Worker void set_status(int status); 860*6777b538SAndroid Build Coastguard Worker 861*6777b538SAndroid Build Coastguard Worker // Returns true if the request failed or was cancelled. 862*6777b538SAndroid Build Coastguard Worker bool failed() const; 863*6777b538SAndroid Build Coastguard Worker 864*6777b538SAndroid Build Coastguard Worker // Returns the error status of the request. 865*6777b538SAndroid Build Coastguard Worker 866*6777b538SAndroid Build Coastguard Worker // Allow the URLRequestJob to redirect this request. If non-null, 867*6777b538SAndroid Build Coastguard Worker // |removed_headers| and |modified_headers| are changes 868*6777b538SAndroid Build Coastguard Worker // applied to the request headers after updating them for the redirect. 869*6777b538SAndroid Build Coastguard Worker void Redirect(const RedirectInfo& redirect_info, 870*6777b538SAndroid Build Coastguard Worker const std::optional<std::vector<std::string>>& removed_headers, 871*6777b538SAndroid Build Coastguard Worker const std::optional<net::HttpRequestHeaders>& modified_headers); 872*6777b538SAndroid Build Coastguard Worker 873*6777b538SAndroid Build Coastguard Worker // Called by URLRequestJob to allow interception when a redirect occurs. 874*6777b538SAndroid Build Coastguard Worker void NotifyReceivedRedirect(const RedirectInfo& redirect_info, 875*6777b538SAndroid Build Coastguard Worker bool* defer_redirect); 876*6777b538SAndroid Build Coastguard Worker 877*6777b538SAndroid Build Coastguard Worker private: 878*6777b538SAndroid Build Coastguard Worker friend class URLRequestJob; 879*6777b538SAndroid Build Coastguard Worker 880*6777b538SAndroid Build Coastguard Worker // For testing purposes. 881*6777b538SAndroid Build Coastguard Worker // TODO(maksims): Remove this. 882*6777b538SAndroid Build Coastguard Worker friend class TestNetworkDelegate; 883*6777b538SAndroid Build Coastguard Worker 884*6777b538SAndroid Build Coastguard Worker // Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest 885*6777b538SAndroid Build Coastguard Worker // handler. If |blocked| is true, the request is blocked and an error page is 886*6777b538SAndroid Build Coastguard Worker // returned indicating so. This should only be called after Start is called 887*6777b538SAndroid Build Coastguard Worker // and OnBeforeRequest returns true (signalling that the request should be 888*6777b538SAndroid Build Coastguard Worker // paused). 889*6777b538SAndroid Build Coastguard Worker void BeforeRequestComplete(int error); 890*6777b538SAndroid Build Coastguard Worker 891*6777b538SAndroid Build Coastguard Worker void StartJob(std::unique_ptr<URLRequestJob> job); 892*6777b538SAndroid Build Coastguard Worker 893*6777b538SAndroid Build Coastguard Worker // Restarting involves replacing the current job with a new one such as what 894*6777b538SAndroid Build Coastguard Worker // happens when following a HTTP redirect. 895*6777b538SAndroid Build Coastguard Worker void RestartWithJob(std::unique_ptr<URLRequestJob> job); 896*6777b538SAndroid Build Coastguard Worker void PrepareToRestart(); 897*6777b538SAndroid Build Coastguard Worker 898*6777b538SAndroid Build Coastguard Worker // Cancels the request and set the error and ssl info for this request to the 899*6777b538SAndroid Build Coastguard Worker // passed values. Returns the error that was set. 900*6777b538SAndroid Build Coastguard Worker int DoCancel(int error, const SSLInfo& ssl_info); 901*6777b538SAndroid Build Coastguard Worker 902*6777b538SAndroid Build Coastguard Worker // Called by the URLRequestJob when the headers are received, before any other 903*6777b538SAndroid Build Coastguard Worker // method, to allow caching of load timing information. 904*6777b538SAndroid Build Coastguard Worker void OnHeadersComplete(); 905*6777b538SAndroid Build Coastguard Worker 906*6777b538SAndroid Build Coastguard Worker // Notifies the network delegate that the request has been completed. 907*6777b538SAndroid Build Coastguard Worker // This does not imply a successful completion. Also a canceled request is 908*6777b538SAndroid Build Coastguard Worker // considered completed. 909*6777b538SAndroid Build Coastguard Worker void NotifyRequestCompleted(); 910*6777b538SAndroid Build Coastguard Worker 911*6777b538SAndroid Build Coastguard Worker // Called by URLRequestJob to allow interception when the final response 912*6777b538SAndroid Build Coastguard Worker // occurs. 913*6777b538SAndroid Build Coastguard Worker void NotifyResponseStarted(int net_error); 914*6777b538SAndroid Build Coastguard Worker 915*6777b538SAndroid Build Coastguard Worker // These functions delegate to |delegate_|. See URLRequest::Delegate for the 916*6777b538SAndroid Build Coastguard Worker // meaning of these functions. 917*6777b538SAndroid Build Coastguard Worker int NotifyConnected(const TransportInfo& info, 918*6777b538SAndroid Build Coastguard Worker CompletionOnceCallback callback); 919*6777b538SAndroid Build Coastguard Worker void NotifyAuthRequired(std::unique_ptr<AuthChallengeInfo> auth_info); 920*6777b538SAndroid Build Coastguard Worker void NotifyCertificateRequested(SSLCertRequestInfo* cert_request_info); 921*6777b538SAndroid Build Coastguard Worker void NotifySSLCertificateError(int net_error, 922*6777b538SAndroid Build Coastguard Worker const SSLInfo& ssl_info, 923*6777b538SAndroid Build Coastguard Worker bool fatal); 924*6777b538SAndroid Build Coastguard Worker void NotifyReadCompleted(int bytes_read); 925*6777b538SAndroid Build Coastguard Worker 926*6777b538SAndroid Build Coastguard Worker // This function delegates to the NetworkDelegate if it is not nullptr. 927*6777b538SAndroid Build Coastguard Worker // Otherwise, cookies can be used unless SetDefaultCookiePolicyToBlock() has 928*6777b538SAndroid Build Coastguard Worker // been called. 929*6777b538SAndroid Build Coastguard Worker bool CanSetCookie(const net::CanonicalCookie& cookie, 930*6777b538SAndroid Build Coastguard Worker CookieOptions* options, 931*6777b538SAndroid Build Coastguard Worker const net::FirstPartySetMetadata& first_party_set_metadata, 932*6777b538SAndroid Build Coastguard Worker CookieInclusionStatus* inclusion_status) const; 933*6777b538SAndroid Build Coastguard Worker 934*6777b538SAndroid Build Coastguard Worker // Called just before calling a delegate that may block a request. |type| 935*6777b538SAndroid Build Coastguard Worker // should be the delegate's event type, 936*6777b538SAndroid Build Coastguard Worker // e.g. NetLogEventType::NETWORK_DELEGATE_AUTH_REQUIRED. 937*6777b538SAndroid Build Coastguard Worker void OnCallToDelegate(NetLogEventType type); 938*6777b538SAndroid Build Coastguard Worker // Called when the delegate lets a request continue. Also called on 939*6777b538SAndroid Build Coastguard Worker // cancellation. `error` is an optional error code associated with 940*6777b538SAndroid Build Coastguard Worker // completion. It's only for logging purposes, and will not directly cancel 941*6777b538SAndroid Build Coastguard Worker // the request if it's a value other than OK. 942*6777b538SAndroid Build Coastguard Worker void OnCallToDelegateComplete(int error = OK); 943*6777b538SAndroid Build Coastguard Worker 944*6777b538SAndroid Build Coastguard Worker // Records the referrer policy of the given request, bucketed by 945*6777b538SAndroid Build Coastguard Worker // whether the request is same-origin or not. To save computation, 946*6777b538SAndroid Build Coastguard Worker // takes this fact as a boolean parameter rather than dynamically 947*6777b538SAndroid Build Coastguard Worker // checking. 948*6777b538SAndroid Build Coastguard Worker void RecordReferrerGranularityMetrics(bool request_is_same_origin) const; 949*6777b538SAndroid Build Coastguard Worker 950*6777b538SAndroid Build Coastguard Worker // Creates a partial IsolationInfo with the information accessible from the 951*6777b538SAndroid Build Coastguard Worker // NetworkAnonymiationKey. 952*6777b538SAndroid Build Coastguard Worker net::IsolationInfo CreateIsolationInfoFromNetworkAnonymizationKey( 953*6777b538SAndroid Build Coastguard Worker const NetworkAnonymizationKey& network_anonymization_key); 954*6777b538SAndroid Build Coastguard Worker 955*6777b538SAndroid Build Coastguard Worker // Contextual information used for this request. Cannot be NULL. This contains 956*6777b538SAndroid Build Coastguard Worker // most of the dependencies which are shared between requests (disk cache, 957*6777b538SAndroid Build Coastguard Worker // cookie store, socket pool, etc.) 958*6777b538SAndroid Build Coastguard Worker raw_ptr<const URLRequestContext> context_; 959*6777b538SAndroid Build Coastguard Worker 960*6777b538SAndroid Build Coastguard Worker // Tracks the time spent in various load states throughout this request. 961*6777b538SAndroid Build Coastguard Worker NetLogWithSource net_log_; 962*6777b538SAndroid Build Coastguard Worker 963*6777b538SAndroid Build Coastguard Worker std::unique_ptr<URLRequestJob> job_; 964*6777b538SAndroid Build Coastguard Worker std::unique_ptr<UploadDataStream> upload_data_stream_; 965*6777b538SAndroid Build Coastguard Worker 966*6777b538SAndroid Build Coastguard Worker std::vector<GURL> url_chain_; 967*6777b538SAndroid Build Coastguard Worker SiteForCookies site_for_cookies_; 968*6777b538SAndroid Build Coastguard Worker 969*6777b538SAndroid Build Coastguard Worker IsolationInfo isolation_info_; 970*6777b538SAndroid Build Coastguard Worker // The cookie partition key for the request. Partitioned cookies should be set 971*6777b538SAndroid Build Coastguard Worker // using this key and only partitioned cookies with this partition key should 972*6777b538SAndroid Build Coastguard Worker // be sent. The cookie partition key is optional(nullopt) if cookie 973*6777b538SAndroid Build Coastguard Worker // partitioning is not enabled, or if the NIK has no top-frame site. 974*6777b538SAndroid Build Coastguard Worker // 975*6777b538SAndroid Build Coastguard Worker // Unpartitioned cookies are unaffected by this field. 976*6777b538SAndroid Build Coastguard Worker std::optional<CookiePartitionKey> cookie_partition_key_ = std::nullopt; 977*6777b538SAndroid Build Coastguard Worker 978*6777b538SAndroid Build Coastguard Worker bool force_ignore_site_for_cookies_ = false; 979*6777b538SAndroid Build Coastguard Worker bool force_main_frame_for_same_site_cookies_ = false; 980*6777b538SAndroid Build Coastguard Worker CookieSettingOverrides cookie_setting_overrides_; 981*6777b538SAndroid Build Coastguard Worker 982*6777b538SAndroid Build Coastguard Worker std::optional<url::Origin> initiator_; 983*6777b538SAndroid Build Coastguard Worker GURL delegate_redirect_url_; 984*6777b538SAndroid Build Coastguard Worker std::string method_; // "GET", "POST", etc. Case-sensitive. 985*6777b538SAndroid Build Coastguard Worker std::string referrer_; 986*6777b538SAndroid Build Coastguard Worker ReferrerPolicy referrer_policy_ = 987*6777b538SAndroid Build Coastguard Worker ReferrerPolicy::CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE; 988*6777b538SAndroid Build Coastguard Worker RedirectInfo::FirstPartyURLPolicy first_party_url_policy_ = 989*6777b538SAndroid Build Coastguard Worker RedirectInfo::FirstPartyURLPolicy::NEVER_CHANGE_URL; 990*6777b538SAndroid Build Coastguard Worker HttpRequestHeaders extra_request_headers_; 991*6777b538SAndroid Build Coastguard Worker // Flags indicating the request type for the load. Expected values are LOAD_* 992*6777b538SAndroid Build Coastguard Worker // enums above. 993*6777b538SAndroid Build Coastguard Worker int load_flags_ = LOAD_NORMAL; 994*6777b538SAndroid Build Coastguard Worker // Whether the request is allowed to send credentials in general. Set by 995*6777b538SAndroid Build Coastguard Worker // caller. 996*6777b538SAndroid Build Coastguard Worker bool allow_credentials_ = true; 997*6777b538SAndroid Build Coastguard Worker // Whether the request is eligible for using storage access permission grant 998*6777b538SAndroid Build Coastguard Worker // if one exists. Only set by caller when constructed and will not change 999*6777b538SAndroid Build Coastguard Worker // during redirects. 1000*6777b538SAndroid Build Coastguard Worker bool has_storage_access_ = false; 1001*6777b538SAndroid Build Coastguard Worker SecureDnsPolicy secure_dns_policy_ = SecureDnsPolicy::kAllow; 1002*6777b538SAndroid Build Coastguard Worker 1003*6777b538SAndroid Build Coastguard Worker CookieAccessResultList maybe_sent_cookies_; 1004*6777b538SAndroid Build Coastguard Worker CookieAndLineAccessResultList maybe_stored_cookies_; 1005*6777b538SAndroid Build Coastguard Worker 1006*6777b538SAndroid Build Coastguard Worker #if BUILDFLAG(ENABLE_REPORTING) 1007*6777b538SAndroid Build Coastguard Worker int reporting_upload_depth_ = 0; 1008*6777b538SAndroid Build Coastguard Worker #endif 1009*6777b538SAndroid Build Coastguard Worker 1010*6777b538SAndroid Build Coastguard Worker // Never access methods of the |delegate_| directly. Always use the 1011*6777b538SAndroid Build Coastguard Worker // Notify... methods for this. 1012*6777b538SAndroid Build Coastguard Worker raw_ptr<Delegate> delegate_; 1013*6777b538SAndroid Build Coastguard Worker 1014*6777b538SAndroid Build Coastguard Worker const bool is_for_websockets_; 1015*6777b538SAndroid Build Coastguard Worker 1016*6777b538SAndroid Build Coastguard Worker // Current error status of the job, as a net::Error code. When the job is 1017*6777b538SAndroid Build Coastguard Worker // busy, it is ERR_IO_PENDING. When the job is idle (either completed, or 1018*6777b538SAndroid Build Coastguard Worker // awaiting a call from the URLRequestDelegate before continuing the request), 1019*6777b538SAndroid Build Coastguard Worker // it is OK. If the request has been cancelled without a specific error, it is 1020*6777b538SAndroid Build Coastguard Worker // ERR_ABORTED. And on failure, it's the corresponding error code for that 1021*6777b538SAndroid Build Coastguard Worker // error. 1022*6777b538SAndroid Build Coastguard Worker // 1023*6777b538SAndroid Build Coastguard Worker // |status_| may bounce between ERR_IO_PENDING and OK as a request proceeds, 1024*6777b538SAndroid Build Coastguard Worker // but once an error is encountered or the request is canceled, it will take 1025*6777b538SAndroid Build Coastguard Worker // the appropriate error code and never change again. If multiple failures 1026*6777b538SAndroid Build Coastguard Worker // have been encountered, this will be the first error encountered. 1027*6777b538SAndroid Build Coastguard Worker int status_ = OK; 1028*6777b538SAndroid Build Coastguard Worker 1029*6777b538SAndroid Build Coastguard Worker bool is_created_from_network_anonymization_key_ = false; 1030*6777b538SAndroid Build Coastguard Worker 1031*6777b538SAndroid Build Coastguard Worker // The HTTP response info, lazily initialized. 1032*6777b538SAndroid Build Coastguard Worker HttpResponseInfo response_info_; 1033*6777b538SAndroid Build Coastguard Worker 1034*6777b538SAndroid Build Coastguard Worker // Tells us whether the job is outstanding. This is true from the time 1035*6777b538SAndroid Build Coastguard Worker // Start() is called to the time we dispatch RequestComplete and indicates 1036*6777b538SAndroid Build Coastguard Worker // whether the job is active. 1037*6777b538SAndroid Build Coastguard Worker bool is_pending_ = false; 1038*6777b538SAndroid Build Coastguard Worker 1039*6777b538SAndroid Build Coastguard Worker // Indicates if the request is in the process of redirecting to a new 1040*6777b538SAndroid Build Coastguard Worker // location. It is true from the time the headers complete until a 1041*6777b538SAndroid Build Coastguard Worker // new request begins. 1042*6777b538SAndroid Build Coastguard Worker bool is_redirecting_ = false; 1043*6777b538SAndroid Build Coastguard Worker 1044*6777b538SAndroid Build Coastguard Worker // Number of times we're willing to redirect. Used to guard against 1045*6777b538SAndroid Build Coastguard Worker // infinite redirects. 1046*6777b538SAndroid Build Coastguard Worker int redirect_limit_; 1047*6777b538SAndroid Build Coastguard Worker 1048*6777b538SAndroid Build Coastguard Worker // Cached value for use after we've orphaned the job handling the 1049*6777b538SAndroid Build Coastguard Worker // first transaction in a request involving redirects. 1050*6777b538SAndroid Build Coastguard Worker UploadProgress final_upload_progress_; 1051*6777b538SAndroid Build Coastguard Worker 1052*6777b538SAndroid Build Coastguard Worker // The priority level for this request. Objects like 1053*6777b538SAndroid Build Coastguard Worker // ClientSocketPool use this to determine which URLRequest to 1054*6777b538SAndroid Build Coastguard Worker // allocate sockets to first. 1055*6777b538SAndroid Build Coastguard Worker RequestPriority priority_; 1056*6777b538SAndroid Build Coastguard Worker 1057*6777b538SAndroid Build Coastguard Worker // The incremental flag for this request that indicates if it should be 1058*6777b538SAndroid Build Coastguard Worker // loaded concurrently with other resources of the same priority for 1059*6777b538SAndroid Build Coastguard Worker // protocols that support HTTP extensible priorities (RFC 9218). 1060*6777b538SAndroid Build Coastguard Worker // Currently only used in HTTP/3. 1061*6777b538SAndroid Build Coastguard Worker bool priority_incremental_ = kDefaultPriorityIncremental; 1062*6777b538SAndroid Build Coastguard Worker 1063*6777b538SAndroid Build Coastguard Worker // If |calling_delegate_| is true, the event type of the delegate being 1064*6777b538SAndroid Build Coastguard Worker // called. 1065*6777b538SAndroid Build Coastguard Worker NetLogEventType delegate_event_type_ = NetLogEventType::FAILED; 1066*6777b538SAndroid Build Coastguard Worker 1067*6777b538SAndroid Build Coastguard Worker // True if this request is currently calling a delegate, or is blocked waiting 1068*6777b538SAndroid Build Coastguard Worker // for the URL request or network delegate to resume it. 1069*6777b538SAndroid Build Coastguard Worker bool calling_delegate_ = false; 1070*6777b538SAndroid Build Coastguard Worker 1071*6777b538SAndroid Build Coastguard Worker // An optional parameter that provides additional information about what 1072*6777b538SAndroid Build Coastguard Worker // |this| is currently being blocked by. 1073*6777b538SAndroid Build Coastguard Worker std::string blocked_by_; 1074*6777b538SAndroid Build Coastguard Worker bool use_blocked_by_as_load_param_ = false; 1075*6777b538SAndroid Build Coastguard Worker 1076*6777b538SAndroid Build Coastguard Worker // Safe-guard to ensure that we do not send multiple "I am completed" 1077*6777b538SAndroid Build Coastguard Worker // messages to network delegate. 1078*6777b538SAndroid Build Coastguard Worker // TODO(battre): Remove this. http://crbug.com/89049 1079*6777b538SAndroid Build Coastguard Worker bool has_notified_completion_ = false; 1080*6777b538SAndroid Build Coastguard Worker 1081*6777b538SAndroid Build Coastguard Worker int64_t received_response_content_length_ = 0; 1082*6777b538SAndroid Build Coastguard Worker 1083*6777b538SAndroid Build Coastguard Worker base::TimeTicks creation_time_; 1084*6777b538SAndroid Build Coastguard Worker 1085*6777b538SAndroid Build Coastguard Worker // Timing information for the most recent request. Its start times are 1086*6777b538SAndroid Build Coastguard Worker // populated during Start(), and the rest are populated in OnResponseReceived. 1087*6777b538SAndroid Build Coastguard Worker LoadTimingInfo load_timing_info_; 1088*6777b538SAndroid Build Coastguard Worker 1089*6777b538SAndroid Build Coastguard Worker // The proxy chain used for this request, if any. 1090*6777b538SAndroid Build Coastguard Worker ProxyChain proxy_chain_; 1091*6777b538SAndroid Build Coastguard Worker 1092*6777b538SAndroid Build Coastguard Worker // If not null, the network service will not advertise any stream types 1093*6777b538SAndroid Build Coastguard Worker // (via Accept-Encoding) that are not listed. Also, it will not attempt 1094*6777b538SAndroid Build Coastguard Worker // decoding any non-listed stream types. 1095*6777b538SAndroid Build Coastguard Worker std::optional<base::flat_set<net::SourceStream::SourceType>> 1096*6777b538SAndroid Build Coastguard Worker accepted_stream_types_; 1097*6777b538SAndroid Build Coastguard Worker 1098*6777b538SAndroid Build Coastguard Worker const NetworkTrafficAnnotationTag traffic_annotation_; 1099*6777b538SAndroid Build Coastguard Worker 1100*6777b538SAndroid Build Coastguard Worker SocketTag socket_tag_; 1101*6777b538SAndroid Build Coastguard Worker 1102*6777b538SAndroid Build Coastguard Worker // See Set{Request|Response,EarlyResponse}HeadersCallback() above for details. 1103*6777b538SAndroid Build Coastguard Worker RequestHeadersCallback request_headers_callback_; 1104*6777b538SAndroid Build Coastguard Worker ResponseHeadersCallback early_response_headers_callback_; 1105*6777b538SAndroid Build Coastguard Worker ResponseHeadersCallback response_headers_callback_; 1106*6777b538SAndroid Build Coastguard Worker 1107*6777b538SAndroid Build Coastguard Worker // See SetIsSharedDictionaryReadAllowedCallback() above for details. 1108*6777b538SAndroid Build Coastguard Worker base::RepeatingCallback<bool()> is_shared_dictionary_read_allowed_callback_; 1109*6777b538SAndroid Build Coastguard Worker 1110*6777b538SAndroid Build Coastguard Worker bool upgrade_if_insecure_ = false; 1111*6777b538SAndroid Build Coastguard Worker 1112*6777b538SAndroid Build Coastguard Worker bool ad_tagged_ = false; 1113*6777b538SAndroid Build Coastguard Worker 1114*6777b538SAndroid Build Coastguard Worker bool send_client_certs_ = true; 1115*6777b538SAndroid Build Coastguard Worker 1116*6777b538SAndroid Build Coastguard Worker // Idempotency of the request. 1117*6777b538SAndroid Build Coastguard Worker Idempotency idempotency_ = DEFAULT_IDEMPOTENCY; 1118*6777b538SAndroid Build Coastguard Worker 1119*6777b538SAndroid Build Coastguard Worker THREAD_CHECKER(thread_checker_); 1120*6777b538SAndroid Build Coastguard Worker 1121*6777b538SAndroid Build Coastguard Worker base::WeakPtrFactory<URLRequest> weak_factory_{this}; 1122*6777b538SAndroid Build Coastguard Worker }; 1123*6777b538SAndroid Build Coastguard Worker 1124*6777b538SAndroid Build Coastguard Worker } // namespace net 1125*6777b538SAndroid Build Coastguard Worker 1126*6777b538SAndroid Build Coastguard Worker #endif // NET_URL_REQUEST_URL_REQUEST_H_ 1127