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 #include "net/url_request/url_request_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/file_version_info.h" | 12 #include "base/file_version_info.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/rand_util.h" | 16 #include "base/rand_util.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "net/base/host_port_pair.h" | 19 #include "net/base/host_port_pair.h" |
20 #include "net/base/load_flags.h" | 20 #include "net/base/load_flags.h" |
21 #include "net/base/mime_util.h" | 21 #include "net/base/mime_util.h" |
22 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
23 #include "net/base/net_util.h" | 23 #include "net/base/net_util.h" |
24 #include "net/base/network_delegate.h" | 24 #include "net/base/network_delegate.h" |
25 #include "net/base/sdch_manager.h" | 25 #include "net/base/sdch_manager.h" |
26 #include "net/cert/cert_status_flags.h" | 26 #include "net/cert/cert_status_flags.h" |
27 #include "net/cookies/cookie_monster.h" | 27 #include "net/cookies/cookie_monster.h" |
| 28 #include "net/http/http_content_disposition.h" |
28 #include "net/http/http_network_session.h" | 29 #include "net/http/http_network_session.h" |
29 #include "net/http/http_request_headers.h" | 30 #include "net/http/http_request_headers.h" |
30 #include "net/http/http_response_headers.h" | 31 #include "net/http/http_response_headers.h" |
31 #include "net/http/http_response_info.h" | 32 #include "net/http/http_response_info.h" |
32 #include "net/http/http_status_code.h" | 33 #include "net/http/http_status_code.h" |
33 #include "net/http/http_transaction.h" | 34 #include "net/http/http_transaction.h" |
34 #include "net/http/http_transaction_factory.h" | 35 #include "net/http/http_transaction_factory.h" |
35 #include "net/http/http_util.h" | 36 #include "net/http/http_util.h" |
36 #include "net/ssl/ssl_cert_request_info.h" | 37 #include "net/ssl/ssl_cert_request_info.h" |
37 #include "net/ssl/ssl_config_service.h" | 38 #include "net/ssl/ssl_config_service.h" |
(...skipping 13 matching lines...) Expand all Loading... |
51 namespace net { | 52 namespace net { |
52 | 53 |
53 class URLRequestHttpJob::HttpFilterContext : public FilterContext { | 54 class URLRequestHttpJob::HttpFilterContext : public FilterContext { |
54 public: | 55 public: |
55 explicit HttpFilterContext(URLRequestHttpJob* job); | 56 explicit HttpFilterContext(URLRequestHttpJob* job); |
56 virtual ~HttpFilterContext(); | 57 virtual ~HttpFilterContext(); |
57 | 58 |
58 // FilterContext implementation. | 59 // FilterContext implementation. |
59 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 60 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
60 virtual bool GetURL(GURL* gurl) const OVERRIDE; | 61 virtual bool GetURL(GURL* gurl) const OVERRIDE; |
| 62 virtual bool GetContentDisposition(std::string* disposition) const OVERRIDE; |
61 virtual base::Time GetRequestTime() const OVERRIDE; | 63 virtual base::Time GetRequestTime() const OVERRIDE; |
62 virtual bool IsCachedContent() const OVERRIDE; | 64 virtual bool IsCachedContent() const OVERRIDE; |
63 virtual bool IsDownload() const OVERRIDE; | 65 virtual bool IsDownload() const OVERRIDE; |
64 virtual bool IsSdchResponse() const OVERRIDE; | 66 virtual bool IsSdchResponse() const OVERRIDE; |
65 virtual int64 GetByteReadCount() const OVERRIDE; | 67 virtual int64 GetByteReadCount() const OVERRIDE; |
66 virtual int GetResponseCode() const OVERRIDE; | 68 virtual int GetResponseCode() const OVERRIDE; |
67 virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE; | 69 virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE; |
68 | 70 |
69 // Method to allow us to reset filter context for a response that should have | 71 // Method to allow us to reset filter context for a response that should have |
70 // been SDCH encoded when there is an update due to an explicit HTTP header. | 72 // been SDCH encoded when there is an update due to an explicit HTTP header. |
(...skipping 18 matching lines...) Expand all Loading... |
89 return job_->GetMimeType(mime_type); | 91 return job_->GetMimeType(mime_type); |
90 } | 92 } |
91 | 93 |
92 bool URLRequestHttpJob::HttpFilterContext::GetURL(GURL* gurl) const { | 94 bool URLRequestHttpJob::HttpFilterContext::GetURL(GURL* gurl) const { |
93 if (!job_->request()) | 95 if (!job_->request()) |
94 return false; | 96 return false; |
95 *gurl = job_->request()->url(); | 97 *gurl = job_->request()->url(); |
96 return true; | 98 return true; |
97 } | 99 } |
98 | 100 |
| 101 bool URLRequestHttpJob::HttpFilterContext::GetContentDisposition( |
| 102 std::string* disposition) const { |
| 103 HttpResponseHeaders* headers = job_->GetResponseHeaders(); |
| 104 void *iter = NULL; |
| 105 return headers->EnumerateHeader(&iter, "Content-Disposition", disposition); |
| 106 } |
| 107 |
99 base::Time URLRequestHttpJob::HttpFilterContext::GetRequestTime() const { | 108 base::Time URLRequestHttpJob::HttpFilterContext::GetRequestTime() const { |
100 return job_->request() ? job_->request()->request_time() : base::Time(); | 109 return job_->request() ? job_->request()->request_time() : base::Time(); |
101 } | 110 } |
102 | 111 |
103 bool URLRequestHttpJob::HttpFilterContext::IsCachedContent() const { | 112 bool URLRequestHttpJob::HttpFilterContext::IsCachedContent() const { |
104 return job_->is_cached_content_; | 113 return job_->is_cached_content_; |
105 } | 114 } |
106 | 115 |
107 bool URLRequestHttpJob::HttpFilterContext::IsDownload() const { | 116 bool URLRequestHttpJob::HttpFilterContext::IsDownload() const { |
108 return (job_->request_info_.load_flags & LOAD_IS_DOWNLOAD) != 0; | 117 return (job_->request_info_.load_flags & LOAD_IS_DOWNLOAD) != 0; |
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 return override_response_headers_.get() ? | 1473 return override_response_headers_.get() ? |
1465 override_response_headers_.get() : | 1474 override_response_headers_.get() : |
1466 transaction_->GetResponseInfo()->headers.get(); | 1475 transaction_->GetResponseInfo()->headers.get(); |
1467 } | 1476 } |
1468 | 1477 |
1469 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1478 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
1470 awaiting_callback_ = false; | 1479 awaiting_callback_ = false; |
1471 } | 1480 } |
1472 | 1481 |
1473 } // namespace net | 1482 } // namespace net |
OLD | NEW |