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