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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 | 407 |
408 if (transaction_.get()) { | 408 if (transaction_.get()) { |
409 rv = transaction_->RestartWithAuth(auth_credentials_, start_callback_); | 409 rv = transaction_->RestartWithAuth(auth_credentials_, start_callback_); |
410 auth_credentials_ = AuthCredentials(); | 410 auth_credentials_ = AuthCredentials(); |
411 } else { | 411 } else { |
412 DCHECK(request_->context()->http_transaction_factory()); | 412 DCHECK(request_->context()->http_transaction_factory()); |
413 | 413 |
414 rv = request_->context()->http_transaction_factory()->CreateTransaction( | 414 rv = request_->context()->http_transaction_factory()->CreateTransaction( |
415 priority_, &transaction_); | 415 priority_, &transaction_); |
416 | 416 |
| 417 transaction_->SetBeforeNetworkStartCallback(base::Bind( |
| 418 &URLRequestHttpJob::NotifyBeforeNetworkStart, base::Unretained(this))); |
| 419 |
417 if (rv == OK && request_info_.url.SchemeIsWSOrWSS()) { | 420 if (rv == OK && request_info_.url.SchemeIsWSOrWSS()) { |
418 // TODO(ricea): Implement WebSocket throttling semantics as defined in | 421 // TODO(ricea): Implement WebSocket throttling semantics as defined in |
419 // RFC6455 Section 4.1. | 422 // RFC6455 Section 4.1. |
420 base::SupportsUserData::Data* data = request_->GetUserData( | 423 base::SupportsUserData::Data* data = request_->GetUserData( |
421 WebSocketHandshakeStreamBase::CreateHelper::DataKey()); | 424 WebSocketHandshakeStreamBase::CreateHelper::DataKey()); |
422 if (data) { | 425 if (data) { |
423 transaction_->SetWebSocketHandshakeStreamCreateHelper( | 426 transaction_->SetWebSocketHandshakeStreamCreateHelper( |
424 static_cast<WebSocketHandshakeStreamBase::CreateHelper*>(data)); | 427 static_cast<WebSocketHandshakeStreamBase::CreateHelper*>(data)); |
425 } else { | 428 } else { |
426 rv = ERR_DISALLOWED_URL_SCHEME; | 429 rv = ERR_DISALLOWED_URL_SCHEME; |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 return; | 1163 return; |
1161 | 1164 |
1162 // The transaction started synchronously, but we need to notify the | 1165 // The transaction started synchronously, but we need to notify the |
1163 // URLRequest delegate via the message loop. | 1166 // URLRequest delegate via the message loop. |
1164 base::MessageLoop::current()->PostTask( | 1167 base::MessageLoop::current()->PostTask( |
1165 FROM_HERE, | 1168 FROM_HERE, |
1166 base::Bind(&URLRequestHttpJob::OnStartCompleted, | 1169 base::Bind(&URLRequestHttpJob::OnStartCompleted, |
1167 weak_factory_.GetWeakPtr(), rv)); | 1170 weak_factory_.GetWeakPtr(), rv)); |
1168 } | 1171 } |
1169 | 1172 |
| 1173 void URLRequestHttpJob::ResumeNetworkStart() { |
| 1174 DCHECK(transaction_.get()); |
| 1175 transaction_->ResumeNetworkStart(); |
| 1176 } |
| 1177 |
1170 bool URLRequestHttpJob::ShouldFixMismatchedContentLength(int rv) const { | 1178 bool URLRequestHttpJob::ShouldFixMismatchedContentLength(int rv) const { |
1171 // Some servers send the body compressed, but specify the content length as | 1179 // Some servers send the body compressed, but specify the content length as |
1172 // the uncompressed size. Although this violates the HTTP spec we want to | 1180 // the uncompressed size. Although this violates the HTTP spec we want to |
1173 // support it (as IE and FireFox do), but *only* for an exact match. | 1181 // support it (as IE and FireFox do), but *only* for an exact match. |
1174 // See http://crbug.com/79694. | 1182 // See http://crbug.com/79694. |
1175 if (rv == net::ERR_CONTENT_LENGTH_MISMATCH || | 1183 if (rv == net::ERR_CONTENT_LENGTH_MISMATCH || |
1176 rv == net::ERR_INCOMPLETE_CHUNKED_ENCODING) { | 1184 rv == net::ERR_INCOMPLETE_CHUNKED_ENCODING) { |
1177 if (request_ && request_->response_headers()) { | 1185 if (request_ && request_->response_headers()) { |
1178 int64 expected_length = request_->response_headers()->GetContentLength(); | 1186 int64 expected_length = request_->response_headers()->GetContentLength(); |
1179 VLOG(1) << __FUNCTION__ << "() " | 1187 VLOG(1) << __FUNCTION__ << "() " |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 return override_response_headers_.get() ? | 1454 return override_response_headers_.get() ? |
1447 override_response_headers_.get() : | 1455 override_response_headers_.get() : |
1448 transaction_->GetResponseInfo()->headers.get(); | 1456 transaction_->GetResponseInfo()->headers.get(); |
1449 } | 1457 } |
1450 | 1458 |
1451 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1459 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
1452 awaiting_callback_ = false; | 1460 awaiting_callback_ = false; |
1453 } | 1461 } |
1454 | 1462 |
1455 } // namespace net | 1463 } // namespace net |
OLD | NEW |