| 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" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 explicit HttpFilterContext(URLRequestHttpJob* job); | 57 explicit HttpFilterContext(URLRequestHttpJob* job); |
| 58 virtual ~HttpFilterContext(); | 58 virtual ~HttpFilterContext(); |
| 59 | 59 |
| 60 // FilterContext implementation. | 60 // FilterContext implementation. |
| 61 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 61 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
| 62 virtual bool GetURL(GURL* gurl) const OVERRIDE; | 62 virtual bool GetURL(GURL* gurl) const OVERRIDE; |
| 63 virtual bool GetContentDisposition(std::string* disposition) const OVERRIDE; | 63 virtual bool GetContentDisposition(std::string* disposition) const OVERRIDE; |
| 64 virtual base::Time GetRequestTime() const OVERRIDE; | 64 virtual base::Time GetRequestTime() const OVERRIDE; |
| 65 virtual bool IsCachedContent() const OVERRIDE; | 65 virtual bool IsCachedContent() const OVERRIDE; |
| 66 virtual bool IsDownload() const OVERRIDE; | 66 virtual bool IsDownload() const OVERRIDE; |
| 67 virtual bool IsSdchResponse() const OVERRIDE; | 67 virtual bool SdchResponseExpected() const OVERRIDE; |
| 68 virtual int64 GetByteReadCount() const OVERRIDE; | 68 virtual int64 GetByteReadCount() const OVERRIDE; |
| 69 virtual int GetResponseCode() const OVERRIDE; | 69 virtual int GetResponseCode() const OVERRIDE; |
| 70 virtual const URLRequestContext* GetURLRequestContext() const OVERRIDE; | 70 virtual const URLRequestContext* GetURLRequestContext() const OVERRIDE; |
| 71 virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE; | 71 virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE; |
| 72 | 72 |
| 73 // Method to allow us to reset filter context for a response that should have | 73 // Method to allow us to reset filter context for a response that should have |
| 74 // been SDCH encoded when there is an update due to an explicit HTTP header. | 74 // been SDCH encoded when there is an update due to an explicit HTTP header. |
| 75 void ResetSdchResponseToFalse(); | 75 void ResetSdchResponseToFalse(); |
| 76 | 76 |
| 77 private: | 77 private: |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 bool URLRequestHttpJob::HttpFilterContext::IsDownload() const { | 118 bool URLRequestHttpJob::HttpFilterContext::IsDownload() const { |
| 119 return (job_->request_info_.load_flags & LOAD_IS_DOWNLOAD) != 0; | 119 return (job_->request_info_.load_flags & LOAD_IS_DOWNLOAD) != 0; |
| 120 } | 120 } |
| 121 | 121 |
| 122 void URLRequestHttpJob::HttpFilterContext::ResetSdchResponseToFalse() { | 122 void URLRequestHttpJob::HttpFilterContext::ResetSdchResponseToFalse() { |
| 123 DCHECK(job_->sdch_dictionary_advertised_); | 123 DCHECK(job_->sdch_dictionary_advertised_); |
| 124 job_->sdch_dictionary_advertised_ = false; | 124 job_->sdch_dictionary_advertised_ = false; |
| 125 } | 125 } |
| 126 | 126 |
| 127 bool URLRequestHttpJob::HttpFilterContext::IsSdchResponse() const { | 127 bool URLRequestHttpJob::HttpFilterContext::SdchResponseExpected() const { |
| 128 return job_->sdch_dictionary_advertised_; | 128 return job_->sdch_dictionary_advertised_; |
| 129 } | 129 } |
| 130 | 130 |
| 131 int64 URLRequestHttpJob::HttpFilterContext::GetByteReadCount() const { | 131 int64 URLRequestHttpJob::HttpFilterContext::GetByteReadCount() const { |
| 132 return job_->filter_input_byte_count(); | 132 return job_->filter_input_byte_count(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 int URLRequestHttpJob::HttpFilterContext::GetResponseCode() const { | 135 int URLRequestHttpJob::HttpFilterContext::GetResponseCode() const { |
| 136 return job_->GetResponseCode(); | 136 return job_->GetResponseCode(); |
| 137 } | 137 } |
| (...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 return NULL; | 1017 return NULL; |
| 1018 | 1018 |
| 1019 std::vector<Filter::FilterType> encoding_types; | 1019 std::vector<Filter::FilterType> encoding_types; |
| 1020 std::string encoding_type; | 1020 std::string encoding_type; |
| 1021 HttpResponseHeaders* headers = GetResponseHeaders(); | 1021 HttpResponseHeaders* headers = GetResponseHeaders(); |
| 1022 void* iter = NULL; | 1022 void* iter = NULL; |
| 1023 while (headers->EnumerateHeader(&iter, "Content-Encoding", &encoding_type)) { | 1023 while (headers->EnumerateHeader(&iter, "Content-Encoding", &encoding_type)) { |
| 1024 encoding_types.push_back(Filter::ConvertEncodingToType(encoding_type)); | 1024 encoding_types.push_back(Filter::ConvertEncodingToType(encoding_type)); |
| 1025 } | 1025 } |
| 1026 | 1026 |
| 1027 if (filter_context_->IsSdchResponse()) { | 1027 if (filter_context_->SdchResponseExpected()) { |
| 1028 // We are wary of proxies that discard or damage SDCH encoding. If a server | 1028 // We are wary of proxies that discard or damage SDCH encoding. If a server |
| 1029 // explicitly states that this is not SDCH content, then we can correct our | 1029 // explicitly states that this is not SDCH content, then we can correct our |
| 1030 // assumption that this is an SDCH response, and avoid the need to recover | 1030 // assumption that this is an SDCH response, and avoid the need to recover |
| 1031 // as though the content is corrupted (when we discover it is not SDCH | 1031 // as though the content is corrupted (when we discover it is not SDCH |
| 1032 // encoded). | 1032 // encoded). |
| 1033 std::string sdch_response_status; | 1033 std::string sdch_response_status; |
| 1034 iter = NULL; | 1034 iter = NULL; |
| 1035 while (headers->EnumerateHeader(&iter, "X-Sdch-Encode", | 1035 while (headers->EnumerateHeader(&iter, "X-Sdch-Encode", |
| 1036 &sdch_response_status)) { | 1036 &sdch_response_status)) { |
| 1037 if (sdch_response_status == "0") { | 1037 if (sdch_response_status == "0") { |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 return override_response_headers_.get() ? | 1522 return override_response_headers_.get() ? |
| 1523 override_response_headers_.get() : | 1523 override_response_headers_.get() : |
| 1524 transaction_->GetResponseInfo()->headers.get(); | 1524 transaction_->GetResponseInfo()->headers.get(); |
| 1525 } | 1525 } |
| 1526 | 1526 |
| 1527 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1527 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
| 1528 awaiting_callback_ = false; | 1528 awaiting_callback_ = false; |
| 1529 } | 1529 } |
| 1530 | 1530 |
| 1531 } // namespace net | 1531 } // namespace net |
| OLD | NEW |