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 = URLRequestStatus(); | |
willchan no longer on Chromium
2011/05/23 22:12:26
I'd prefer if you explicitly set the fields to OK.
ahendrickson
2011/05/24 04:58:37
OK, but this is the way it's done in the rest of t
| |
339 } | |
340 } | |
341 } | |
342 | |
323 RecordCompressionHistograms(); | 343 RecordCompressionHistograms(); |
324 URLRequestJob::NotifyDone(status); | 344 URLRequestJob::NotifyDone(status); |
325 } | 345 } |
326 | 346 |
327 void URLRequestHttpJob::DestroyTransaction() { | 347 void URLRequestHttpJob::DestroyTransaction() { |
328 DCHECK(transaction_.get()); | 348 DCHECK(transaction_.get()); |
329 | 349 |
330 transaction_.reset(); | 350 transaction_.reset(); |
331 response_info_ = NULL; | 351 response_info_ = NULL; |
332 context_ = NULL; | 352 context_ = NULL; |
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1388 } | 1408 } |
1389 | 1409 |
1390 bool URLRequestHttpJob::IsCompressibleContent() const { | 1410 bool URLRequestHttpJob::IsCompressibleContent() const { |
1391 std::string mime_type; | 1411 std::string mime_type; |
1392 return GetMimeType(&mime_type) && | 1412 return GetMimeType(&mime_type) && |
1393 (IsSupportedJavascriptMimeType(mime_type.c_str()) || | 1413 (IsSupportedJavascriptMimeType(mime_type.c_str()) || |
1394 IsSupportedNonImageMimeType(mime_type.c_str())); | 1414 IsSupportedNonImageMimeType(mime_type.c_str())); |
1395 } | 1415 } |
1396 | 1416 |
1397 } // namespace net | 1417 } // namespace net |
OLD | NEW |