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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // notified of the headers completion so that we can update the cookie store. | 312 // notified of the headers completion so that we can update the cookie store. |
313 if (transaction_->IsReadyToRestartForAuth()) { | 313 if (transaction_->IsReadyToRestartForAuth()) { |
314 DCHECK(!response_info_->auth_challenge.get()); | 314 DCHECK(!response_info_->auth_challenge.get()); |
315 RestartTransactionWithAuth(string16(), string16()); | 315 RestartTransactionWithAuth(string16(), string16()); |
316 return; | 316 return; |
317 } | 317 } |
318 | 318 |
319 URLRequestJob::NotifyHeadersComplete(); | 319 URLRequestJob::NotifyHeadersComplete(); |
320 } | 320 } |
321 | 321 |
322 void URLRequestHttpJob::NotifyDone(const URLRequestStatus& status) { | 322 void URLRequestHttpJob::NotifyDone(const URLRequestStatus& original_status) { |
| 323 URLRequestStatus status(original_status); |
| 324 // Some servers send the body compressed, but specify the content length as |
| 325 // the uncompressed size. Although this violates the HTTP spec we want to |
| 326 // support it (as IE and FireFox do), but *only* for an exact match. |
| 327 // See http://crbug.com/79694. |
| 328 if (status.os_error() == net::ERR_CONNECTION_CLOSED) { |
| 329 if (request_ && request_->response_headers()) { |
| 330 int64 expected_length = request_->response_headers()->GetContentLength(); |
| 331 VLOG(1) << __FUNCTION__ << "() " |
| 332 << "\"" << request_->url().spec() << "\"" |
| 333 << " content-length = " << expected_length |
| 334 << " pre total = " << prefilter_bytes_read() |
| 335 << " post total = " << postfilter_bytes_read(); |
| 336 if (postfilter_bytes_read() == expected_length) { |
| 337 // Clear the error. |
| 338 status.set_status(URLRequestStatus::SUCCESS); |
| 339 status.set_os_error(0); |
| 340 } |
| 341 } |
| 342 } |
| 343 |
323 RecordCompressionHistograms(); | 344 RecordCompressionHistograms(); |
324 URLRequestJob::NotifyDone(status); | 345 URLRequestJob::NotifyDone(status); |
325 } | 346 } |
326 | 347 |
327 void URLRequestHttpJob::DestroyTransaction() { | 348 void URLRequestHttpJob::DestroyTransaction() { |
328 DCHECK(transaction_.get()); | 349 DCHECK(transaction_.get()); |
329 | 350 |
330 transaction_.reset(); | 351 transaction_.reset(); |
331 response_info_ = NULL; | 352 response_info_ = NULL; |
332 context_ = NULL; | 353 context_ = NULL; |
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 } | 1409 } |
1389 | 1410 |
1390 bool URLRequestHttpJob::IsCompressibleContent() const { | 1411 bool URLRequestHttpJob::IsCompressibleContent() const { |
1391 std::string mime_type; | 1412 std::string mime_type; |
1392 return GetMimeType(&mime_type) && | 1413 return GetMimeType(&mime_type) && |
1393 (IsSupportedJavascriptMimeType(mime_type.c_str()) || | 1414 (IsSupportedJavascriptMimeType(mime_type.c_str()) || |
1394 IsSupportedNonImageMimeType(mime_type.c_str())); | 1415 IsSupportedNonImageMimeType(mime_type.c_str())); |
1395 } | 1416 } |
1396 | 1417 |
1397 } // namespace net | 1418 } // namespace net |
OLD | NEW |