OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 // notified of the headers completion so that we can update the cookie store. | 276 // notified of the headers completion so that we can update the cookie store. |
277 if (transaction_->IsReadyToRestartForAuth()) { | 277 if (transaction_->IsReadyToRestartForAuth()) { |
278 DCHECK(!response_info_->auth_challenge.get()); | 278 DCHECK(!response_info_->auth_challenge.get()); |
279 RestartTransactionWithAuth(string16(), string16()); | 279 RestartTransactionWithAuth(string16(), string16()); |
280 return; | 280 return; |
281 } | 281 } |
282 | 282 |
283 URLRequestJob::NotifyHeadersComplete(); | 283 URLRequestJob::NotifyHeadersComplete(); |
284 } | 284 } |
285 | 285 |
286 void URLRequestHttpJob::NotifyDone(const URLRequestStatus& status) { | 286 void URLRequestHttpJob::NotifyDone(const URLRequestStatus& original_status) { |
| 287 URLRequestStatus status(original_status); |
| 288 // Some servers send the body compressed, but specify the content length as |
| 289 // the uncompressed size. Although this violates the HTTP spec we want to |
| 290 // support it (as IE and FireFox do), but *only* for an exact match. |
| 291 // See http://crbug.com/79694. |
| 292 if (status.os_error() == net::ERR_CONNECTION_CLOSED) { |
| 293 if (request_ && request_->response_headers()) { |
| 294 int64 expected_length = request_->response_headers()->GetContentLength(); |
| 295 DVLOG(21) << __FUNCTION__ << "() " |
| 296 << "\"" << request_->url().spec() << "\"" |
| 297 << " content-length = " << expected_length |
| 298 << " pre total = " << prefilter_bytes_read() |
| 299 << " post total = " << postfilter_bytes_read(); |
| 300 if (postfilter_bytes_read() == expected_length) { |
| 301 // Clear the error. |
| 302 status = URLRequestStatus(); |
| 303 } |
| 304 } |
| 305 } |
| 306 |
287 RecordCompressionHistograms(); | 307 RecordCompressionHistograms(); |
288 URLRequestJob::NotifyDone(status); | 308 URLRequestJob::NotifyDone(status); |
289 } | 309 } |
290 | 310 |
291 void URLRequestHttpJob::DestroyTransaction() { | 311 void URLRequestHttpJob::DestroyTransaction() { |
292 DCHECK(transaction_.get()); | 312 DCHECK(transaction_.get()); |
293 | 313 |
294 transaction_.reset(); | 314 transaction_.reset(); |
295 response_info_ = NULL; | 315 response_info_ = NULL; |
296 context_ = NULL; | 316 context_ = NULL; |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 } | 1389 } |
1370 | 1390 |
1371 bool URLRequestHttpJob::IsCompressibleContent() const { | 1391 bool URLRequestHttpJob::IsCompressibleContent() const { |
1372 std::string mime_type; | 1392 std::string mime_type; |
1373 return GetMimeType(&mime_type) && | 1393 return GetMimeType(&mime_type) && |
1374 (IsSupportedJavascriptMimeType(mime_type.c_str()) || | 1394 (IsSupportedJavascriptMimeType(mime_type.c_str()) || |
1375 IsSupportedNonImageMimeType(mime_type.c_str())); | 1395 IsSupportedNonImageMimeType(mime_type.c_str())); |
1376 } | 1396 } |
1377 | 1397 |
1378 } // namespace net | 1398 } // namespace net |
OLD | NEW |