| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_URL_REQUEST_URL_REQUEST_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_H_ |
| 6 #define NET_URL_REQUEST_URL_REQUEST_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 // First-party URL redirect policy: During server redirects, the first-party | 112 // First-party URL redirect policy: During server redirects, the first-party |
| 113 // URL for cookies normally doesn't change. However, if the request is a | 113 // URL for cookies normally doesn't change. However, if the request is a |
| 114 // top-level first-party request, the first-party URL should be updated to the | 114 // top-level first-party request, the first-party URL should be updated to the |
| 115 // URL on every redirect. | 115 // URL on every redirect. |
| 116 enum FirstPartyURLPolicy { | 116 enum FirstPartyURLPolicy { |
| 117 NEVER_CHANGE_FIRST_PARTY_URL, | 117 NEVER_CHANGE_FIRST_PARTY_URL, |
| 118 UPDATE_FIRST_PARTY_URL_ON_REDIRECT, | 118 UPDATE_FIRST_PARTY_URL_ON_REDIRECT, |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 // 'Upgrade-Insecure-Requests' gives developers the ability to force some |
| 122 // requests to upgrade themselves to secure transport before hitting the |
| 123 // network (along with any redirects they encounter along the way). The |
| 124 // insecure request policy governs this behavior: |
| 125 // |
| 126 // * DO_NOT_UPGRADE_INSECURE_REQUESTS is the default behavior, which does |
| 127 // not upgrade insecure request (hence the clever name). |
| 128 // |
| 129 // * UPGRADE_ALL_INSECURE_REQUESTS will upgrade any insecure request to |
| 130 // secure transport. |
| 131 // |
| 132 // * UPGRADE_SAME_HOST_INSECURE_REQUESTS will upgrade any insecure request |
| 133 // whose target's host matches the request's initiator's host. |
| 134 // |
| 135 // See https://w3c.github.io/webappsec-upgrade-insecure-requests/ for detail. |
| 136 enum InsecureRequestPolicy { |
| 137 DO_NOT_UPGRADE_INSECURE_REQUESTS, |
| 138 UPGRADE_SAME_HOST_INSECURE_REQUESTS, |
| 139 UPGRADE_ALL_INSECURE_REQUESTS |
| 140 }; |
| 141 |
| 121 // The delegate's methods are called from the message loop of the thread | 142 // The delegate's methods are called from the message loop of the thread |
| 122 // on which the request's Start() method is called. See above for the | 143 // on which the request's Start() method is called. See above for the |
| 123 // ordering of callbacks. | 144 // ordering of callbacks. |
| 124 // | 145 // |
| 125 // The callbacks will be called in the following order: | 146 // The callbacks will be called in the following order: |
| 126 // Start() | 147 // Start() |
| 127 // - OnCertificateRequested* (zero or more calls, if the SSL server and/or | 148 // - OnCertificateRequested* (zero or more calls, if the SSL server and/or |
| 128 // SSL proxy requests a client certificate for authentication) | 149 // SSL proxy requests a client certificate for authentication) |
| 129 // - OnSSLCertificateError* (zero or one call, if the SSL server's | 150 // - OnSSLCertificateError* (zero or one call, if the SSL server's |
| 130 // certificate has an error) | 151 // certificate has an error) |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 // `https://example.com/`'s form submission is made in the top-level frame, | 321 // `https://example.com/`'s form submission is made in the top-level frame, |
| 301 // the first party for cookies would be the target URL's origin. The | 322 // the first party for cookies would be the target URL's origin. The |
| 302 // initiator remains `https://example.com/`. | 323 // initiator remains `https://example.com/`. |
| 303 // | 324 // |
| 304 // This value is used to perform the cross-origin check specified in Section | 325 // This value is used to perform the cross-origin check specified in Section |
| 305 // 4.3 of https://tools.ietf.org/html/draft-west-first-party-cookies. | 326 // 4.3 of https://tools.ietf.org/html/draft-west-first-party-cookies. |
| 306 const url::Origin& initiator() const { return initiator_; } | 327 const url::Origin& initiator() const { return initiator_; } |
| 307 // This method may only be called before Start(). | 328 // This method may only be called before Start(). |
| 308 void set_initiator(const url::Origin& initiator); | 329 void set_initiator(const url::Origin& initiator); |
| 309 | 330 |
| 331 // The insecure request policy to apply to this request. The insecure request |
| 332 // policy may only be changed before Start() is called. |
| 333 InsecureRequestPolicy insecure_request_policy() const { return insecure_reques
t_policy_; } |
| 334 void set_insecure_request_policy(InsecureRequestPolicy insecure_request_policy
); |
| 335 |
| 310 // The request method, as an uppercase string. "GET" is the default value. | 336 // The request method, as an uppercase string. "GET" is the default value. |
| 311 // The request method may only be changed before Start() is called and | 337 // The request method may only be changed before Start() is called and |
| 312 // should only be assigned an uppercase value. | 338 // should only be assigned an uppercase value. |
| 313 const std::string& method() const { return method_; } | 339 const std::string& method() const { return method_; } |
| 314 void set_method(const std::string& method); | 340 void set_method(const std::string& method); |
| 315 | 341 |
| 316 // The referrer URL for the request. This header may actually be suppressed | 342 // The referrer URL for the request. This header may actually be suppressed |
| 317 // from the underlying network request for security reasons (e.g., a HTTPS | 343 // from the underlying network request for security reasons (e.g., a HTTPS |
| 318 // URL will not be sent as the referrer for a HTTP request). The referrer | 344 // URL will not be sent as the referrer for a HTTP request). The referrer |
| 319 // may only be changed before Start() is called. | 345 // may only be changed before Start() is called. |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 int64_t GetExpectedContentSize() const; | 652 int64_t GetExpectedContentSize() const; |
| 627 | 653 |
| 628 // Returns the priority level for this request. | 654 // Returns the priority level for this request. |
| 629 RequestPriority priority() const { return priority_; } | 655 RequestPriority priority() const { return priority_; } |
| 630 | 656 |
| 631 // Sets the priority level for this request and any related | 657 // Sets the priority level for this request and any related |
| 632 // jobs. Must not change the priority to anything other than | 658 // jobs. Must not change the priority to anything other than |
| 633 // MAXIMUM_PRIORITY if the IGNORE_LIMITS load flag is set. | 659 // MAXIMUM_PRIORITY if the IGNORE_LIMITS load flag is set. |
| 634 void SetPriority(RequestPriority priority); | 660 void SetPriority(RequestPriority priority); |
| 635 | 661 |
| 636 // Returns true iff this request would be internally redirected to HTTPS | 662 // Returns true iff this request should be internally redirected to HTTPS |
| 637 // due to HSTS. If so, |redirect_url| is rewritten to the new HTTPS URL. | 663 // due to either HSTS (https://tools.ietf.org/html/rfc6797) or |
| 638 bool GetHSTSRedirect(GURL* redirect_url) const; | 664 // Upgrade-Insecure-Requests |
| 665 // (https://w3c.github.io/webappsec-upgrade-insecure-requests/). If so, |
| 666 // |redirect_url| is rewritten to the new URL, and |type| is set to either |
| 667 // "HSTS" or "Upgrade", accordingly. |
| 668 bool GetSecureRedirect(GURL* redirect_url, std::string* redirect_type) const; |
| 639 | 669 |
| 640 void set_received_response_content_length(int64_t received_content_length) { | 670 void set_received_response_content_length(int64_t received_content_length) { |
| 641 received_response_content_length_ = received_content_length; | 671 received_response_content_length_ = received_content_length; |
| 642 } | 672 } |
| 643 | 673 |
| 644 // The number of bytes in the raw response body (before any decompression, | 674 // The number of bytes in the raw response body (before any decompression, |
| 645 // etc.). This is only available after the final Read completes. Not available | 675 // etc.). This is only available after the final Read completes. Not available |
| 646 // for FTP responses. | 676 // for FTP responses. |
| 647 int64_t received_response_content_length() const { | 677 int64_t received_response_content_length() const { |
| 648 return received_response_content_length_; | 678 return received_response_content_length_; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 | 800 |
| 771 std::vector<GURL> url_chain_; | 801 std::vector<GURL> url_chain_; |
| 772 GURL first_party_for_cookies_; | 802 GURL first_party_for_cookies_; |
| 773 url::Origin initiator_; | 803 url::Origin initiator_; |
| 774 GURL delegate_redirect_url_; | 804 GURL delegate_redirect_url_; |
| 775 std::string method_; // "GET", "POST", etc. Should be all uppercase. | 805 std::string method_; // "GET", "POST", etc. Should be all uppercase. |
| 776 std::string referrer_; | 806 std::string referrer_; |
| 777 ReferrerPolicy referrer_policy_; | 807 ReferrerPolicy referrer_policy_; |
| 778 std::string token_binding_referrer_; | 808 std::string token_binding_referrer_; |
| 779 FirstPartyURLPolicy first_party_url_policy_; | 809 FirstPartyURLPolicy first_party_url_policy_; |
| 810 InsecureRequestPolicy insecure_request_policy_; |
| 780 HttpRequestHeaders extra_request_headers_; | 811 HttpRequestHeaders extra_request_headers_; |
| 781 int load_flags_; // Flags indicating the request type for the load; | 812 int load_flags_; // Flags indicating the request type for the load; |
| 782 // expected values are LOAD_* enums above. | 813 // expected values are LOAD_* enums above. |
| 783 | 814 |
| 784 // Never access methods of the |delegate_| directly. Always use the | 815 // Never access methods of the |delegate_| directly. Always use the |
| 785 // Notify... methods for this. | 816 // Notify... methods for this. |
| 786 Delegate* delegate_; | 817 Delegate* delegate_; |
| 787 | 818 |
| 788 // Current error status of the job. When no error has been encountered, this | 819 // Current error status of the job. When no error has been encountered, this |
| 789 // will be SUCCESS. If multiple errors have been encountered, this will be | 820 // will be SUCCESS. If multiple errors have been encountered, this will be |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 | 896 |
| 866 // The proxy server used for this request, if any. | 897 // The proxy server used for this request, if any. |
| 867 HostPortPair proxy_server_; | 898 HostPortPair proxy_server_; |
| 868 | 899 |
| 869 DISALLOW_COPY_AND_ASSIGN(URLRequest); | 900 DISALLOW_COPY_AND_ASSIGN(URLRequest); |
| 870 }; | 901 }; |
| 871 | 902 |
| 872 } // namespace net | 903 } // namespace net |
| 873 | 904 |
| 874 #endif // NET_URL_REQUEST_URL_REQUEST_H_ | 905 #endif // NET_URL_REQUEST_URL_REQUEST_H_ |
| OLD | NEW |