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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 public base::SupportsUserData { | 75 public base::SupportsUserData { |
76 public: | 76 public: |
77 // Callback function implemented by protocol handlers to create new jobs. | 77 // Callback function implemented by protocol handlers to create new jobs. |
78 // The factory may return NULL to indicate an error, which will cause other | 78 // The factory may return NULL to indicate an error, which will cause other |
79 // factories to be queried. If no factory handles the request, then the | 79 // factories to be queried. If no factory handles the request, then the |
80 // default job will be used. | 80 // default job will be used. |
81 typedef URLRequestJob* (ProtocolFactory)(URLRequest* request, | 81 typedef URLRequestJob* (ProtocolFactory)(URLRequest* request, |
82 NetworkDelegate* network_delegate, | 82 NetworkDelegate* network_delegate, |
83 const std::string& scheme); | 83 const std::string& scheme); |
84 | 84 |
85 // HTTP request/response header IDs (via some preprocessor fun) for use with | |
86 // SetRequestHeaderById and GetResponseHeaderById. | |
87 enum { | |
88 #define HTTP_ATOM(x) HTTP_ ## x, | |
89 #include "net/http/http_atom_list.h" | |
90 #undef HTTP_ATOM | |
91 }; | |
92 | |
93 // Referrer policies (see set_referrer_policy): During server redirects, the | 85 // Referrer policies (see set_referrer_policy): During server redirects, the |
94 // referrer header might be cleared, if the protocol changes from HTTPS to | 86 // referrer header might be cleared, if the protocol changes from HTTPS to |
95 // HTTP. This is the default behavior of URLRequest, corresponding to | 87 // HTTP. This is the default behavior of URLRequest, corresponding to |
96 // CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE. Alternatively, the | 88 // CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE. Alternatively, the |
97 // referrer policy can be set to strip the referrer down to an origin upon | 89 // referrer policy can be set to strip the referrer down to an origin upon |
98 // cross-origin navigation (ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN), or | 90 // cross-origin navigation (ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN), or |
99 // never change the referrer header (NEVER_CLEAR_REFERRER). Embedders will | 91 // never change the referrer header (NEVER_CLEAR_REFERRER). Embedders will |
100 // want to use these options when implementing referrer policy support | 92 // want to use these options when implementing referrer policy support |
101 // (https://w3c.github.io/webappsec/specs/referrer-policy/). | 93 // (https://w3c.github.io/webappsec/specs/referrer-policy/). |
102 // | 94 // |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 319 |
328 // Sets the upload data. | 320 // Sets the upload data. |
329 void set_upload(scoped_ptr<UploadDataStream> upload); | 321 void set_upload(scoped_ptr<UploadDataStream> upload); |
330 | 322 |
331 // Gets the upload data. | 323 // Gets the upload data. |
332 const UploadDataStream* get_upload() const; | 324 const UploadDataStream* get_upload() const; |
333 | 325 |
334 // Returns true if the request has a non-empty message body to upload. | 326 // Returns true if the request has a non-empty message body to upload. |
335 bool has_upload() const; | 327 bool has_upload() const; |
336 | 328 |
337 // Set an extra request header by ID or name, or remove one by name. These | 329 // Set or remove a extra request header. These methods may only be called |
338 // methods may only be called before Start() is called, or before a new | 330 // before Start() is called, or between receiving a redirect and trying to |
339 // redirect in the request chain. | 331 // follow it. |
340 void SetExtraRequestHeaderById(int header_id, const std::string& value, | |
341 bool overwrite); | |
342 void SetExtraRequestHeaderByName(const std::string& name, | 332 void SetExtraRequestHeaderByName(const std::string& name, |
343 const std::string& value, bool overwrite); | 333 const std::string& value, bool overwrite); |
344 void RemoveRequestHeaderByName(const std::string& name); | 334 void RemoveRequestHeaderByName(const std::string& name); |
345 | 335 |
346 // Sets all extra request headers. Any extra request headers set by other | 336 // Sets all extra request headers. Any extra request headers set by other |
347 // methods are overwritten by this method. This method may only be called | 337 // methods are overwritten by this method. This method may only be called |
348 // before Start() is called. It is an error to call it later. | 338 // before Start() is called. It is an error to call it later. |
349 void SetExtraRequestHeaders(const HttpRequestHeaders& headers); | 339 void SetExtraRequestHeaders(const HttpRequestHeaders& headers); |
350 | 340 |
351 const HttpRequestHeaders& extra_request_headers() const { | 341 const HttpRequestHeaders& extra_request_headers() const { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 void LogAndReportBlockedBy(const char* blocked_by); | 384 void LogAndReportBlockedBy(const char* blocked_by); |
395 | 385 |
396 // Logs that the request is no longer blocked by the last caller to | 386 // Logs that the request is no longer blocked by the last caller to |
397 // LogBlockedBy. | 387 // LogBlockedBy. |
398 void LogUnblocked(); | 388 void LogUnblocked(); |
399 | 389 |
400 // Returns the current upload progress in bytes. When the upload data is | 390 // Returns the current upload progress in bytes. When the upload data is |
401 // chunked, size is set to zero, but position will not be. | 391 // chunked, size is set to zero, but position will not be. |
402 UploadProgress GetUploadProgress() const; | 392 UploadProgress GetUploadProgress() const; |
403 | 393 |
404 // Get response header(s) by ID or name. These methods may only be called | 394 // Get response header(s) by name. This method may only be called |
405 // once the delegate's OnResponseStarted method has been called. Headers | 395 // once the delegate's OnResponseStarted method has been called. Headers |
406 // that appear more than once in the response are coalesced, with values | 396 // that appear more than once in the response are coalesced, with values |
407 // separated by commas (per RFC 2616). This will not work with cookies since | 397 // separated by commas (per RFC 2616). This will not work with cookies since |
408 // comma can be used in cookie values. | 398 // comma can be used in cookie values. |
409 // TODO(darin): add API to enumerate response headers. | |
410 void GetResponseHeaderById(int header_id, std::string* value); | |
411 void GetResponseHeaderByName(const std::string& name, std::string* value); | 399 void GetResponseHeaderByName(const std::string& name, std::string* value); |
412 | 400 |
413 // Get all response headers, \n-delimited and \n\0-terminated. This includes | |
414 // the response status line. Restrictions on GetResponseHeaders apply. | |
415 void GetAllResponseHeaders(std::string* headers); | |
416 | |
417 // The time when |this| was constructed. | 401 // The time when |this| was constructed. |
418 base::TimeTicks creation_time() const { return creation_time_; } | 402 base::TimeTicks creation_time() const { return creation_time_; } |
419 | 403 |
420 // The time at which the returned response was requested. For cached | 404 // The time at which the returned response was requested. For cached |
421 // responses, this is the last time the cache entry was validated. | 405 // responses, this is the last time the cache entry was validated. |
422 const base::Time& request_time() const { | 406 const base::Time& request_time() const { |
423 return response_info_.request_time; | 407 return response_info_.request_time; |
424 } | 408 } |
425 | 409 |
426 // The time at which the returned response was generated. For cached | 410 // The time at which the returned response was generated. For cached |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 | 826 |
843 // The proxy server used for this request, if any. | 827 // The proxy server used for this request, if any. |
844 HostPortPair proxy_server_; | 828 HostPortPair proxy_server_; |
845 | 829 |
846 DISALLOW_COPY_AND_ASSIGN(URLRequest); | 830 DISALLOW_COPY_AND_ASSIGN(URLRequest); |
847 }; | 831 }; |
848 | 832 |
849 } // namespace net | 833 } // namespace net |
850 | 834 |
851 #endif // NET_URL_REQUEST_URL_REQUEST_H_ | 835 #endif // NET_URL_REQUEST_URL_REQUEST_H_ |
OLD | NEW |