OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/base/filter.h" | 5 #include "net/base/filter.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "net/base/gzip_filter.h" | 8 #include "net/base/gzip_filter.h" |
9 #include "net/base/bzip2_filter.h" | 9 #include "net/base/bzip2_filter.h" |
10 #include "net/base/sdch_filter.h" | 10 #include "net/base/sdch_filter.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 LowerCaseEqualsASCII(mime_type, kApplicationGzip) || | 85 LowerCaseEqualsASCII(mime_type, kApplicationGzip) || |
86 LowerCaseEqualsASCII(mime_type, kApplicationXGunzip)) | 86 LowerCaseEqualsASCII(mime_type, kApplicationXGunzip)) |
87 // The server has told us that it sent us gziped content with a gzip | 87 // The server has told us that it sent us gziped content with a gzip |
88 // content encoding. Sadly, Apache mistakenly sets these headers for all | 88 // content encoding. Sadly, Apache mistakenly sets these headers for all |
89 // .gz files. We match Firefox's nsHttpChannel::ProcessNormal and ignore | 89 // .gz files. We match Firefox's nsHttpChannel::ProcessNormal and ignore |
90 // the Content-Encoding here. | 90 // the Content-Encoding here. |
91 encoding_types->clear(); | 91 encoding_types->clear(); |
92 return; | 92 return; |
93 } | 93 } |
94 | 94 |
95 if (!is_sdch_response) | 95 if (!is_sdch_response) { |
| 96 if (1 < encoding_types->size()) { |
| 97 // Multiple filters were intended to only be used for SDCH (thus far!) |
| 98 SdchManager::SdchErrorRecovery( |
| 99 SdchManager::MULTIENCODING_FOR_NON_SDCH_REQUEST); |
| 100 } |
| 101 if ((1 == encoding_types->size()) && |
| 102 (FILTER_TYPE_SDCH == encoding_types->front())) { |
| 103 SdchManager::SdchErrorRecovery( |
| 104 SdchManager::SDCH_CONTENT_ENCODE_FOR_NON_SDCH_REQUEST); |
| 105 } |
96 return; | 106 return; |
| 107 } |
97 | 108 |
98 // If content encoding included SDCH, then everything is fine. | 109 // If content encoding included SDCH, then everything is fine. |
99 if (!encoding_types->empty() && | 110 if (!encoding_types->empty() && |
100 (FILTER_TYPE_SDCH == encoding_types->front())) { | 111 (FILTER_TYPE_SDCH == encoding_types->front())) { |
101 // Some proxies (found currently in Argentina) strip the Content-Encoding | 112 // Some proxies (found currently in Argentina) strip the Content-Encoding |
102 // text from "sdch,gzip" to a mere "sdch" without modifying the compressed | 113 // text from "sdch,gzip" to a mere "sdch" without modifying the compressed |
103 // payload. To handle this gracefully, we simulate the "probably" deleted | 114 // payload. To handle this gracefully, we simulate the "probably" deleted |
104 // ",gzip" by appending a tentative gzip decode, which will default to a | 115 // ",gzip" by appending a tentative gzip decode, which will default to a |
105 // no-op pass through filter if it doesn't get gzip headers where expected. | 116 // no-op pass through filter if it doesn't get gzip headers where expected. |
106 if (1 == encoding_types->size()) | 117 if (1 == encoding_types->size()) { |
107 encoding_types->push_back(FILTER_TYPE_GZIP_HELPING_SDCH); | 118 encoding_types->push_back(FILTER_TYPE_GZIP_HELPING_SDCH); |
| 119 SdchManager::SdchErrorRecovery( |
| 120 SdchManager::OPTIONAL_GUNZIP_ENCODING_ADDED); |
| 121 } |
108 return; | 122 return; |
109 } | 123 } |
110 | 124 |
111 // SDCH "search results" protective hack: To make sure we don't break the only | 125 // SDCH "search results" protective hack: To make sure we don't break the only |
112 // currently deployed SDCH enabled server! Be VERY cautious about proxies that | 126 // currently deployed SDCH enabled server! Be VERY cautious about proxies that |
113 // strip all content-encoding to not include sdch. IF we don't see content | 127 // strip all content-encoding to not include sdch. IF we don't see content |
114 // encodings that seem to match what we'd expect from a server that asked us | 128 // encodings that seem to match what we'd expect from a server that asked us |
115 // to use a dictionary (and we advertised said dictionary in the GET), then | 129 // to use a dictionary (and we advertised said dictionary in the GET), then |
116 // we set the encoding to (try to) use SDCH to decode. Note that SDCH will | 130 // we set the encoding to (try to) use SDCH to decode. Note that SDCH will |
117 // degrade into a pass-through filter if it doesn't have a viable dictionary | 131 // degrade into a pass-through filter if it doesn't have a viable dictionary |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 mime_type_ = mime_type; | 320 mime_type_ = mime_type; |
307 if (next_filter_.get()) | 321 if (next_filter_.get()) |
308 next_filter_->SetMimeType(mime_type); | 322 next_filter_->SetMimeType(mime_type); |
309 } | 323 } |
310 | 324 |
311 void Filter::SetConnectTime(const base::Time& time) { | 325 void Filter::SetConnectTime(const base::Time& time) { |
312 connect_time_ = time; | 326 connect_time_ = time; |
313 if (next_filter_.get()) | 327 if (next_filter_.get()) |
314 next_filter_->SetConnectTime(time); | 328 next_filter_->SetConnectTime(time); |
315 } | 329 } |
OLD | NEW |