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 16 matching lines...) Expand all Loading... |
27 #include "net/cookies/cookie_store.h" | 27 #include "net/cookies/cookie_store.h" |
28 #include "net/http/http_content_disposition.h" | 28 #include "net/http/http_content_disposition.h" |
29 #include "net/http/http_network_session.h" | 29 #include "net/http/http_network_session.h" |
30 #include "net/http/http_request_headers.h" | 30 #include "net/http/http_request_headers.h" |
31 #include "net/http/http_response_headers.h" | 31 #include "net/http/http_response_headers.h" |
32 #include "net/http/http_response_info.h" | 32 #include "net/http/http_response_info.h" |
33 #include "net/http/http_status_code.h" | 33 #include "net/http/http_status_code.h" |
34 #include "net/http/http_transaction.h" | 34 #include "net/http/http_transaction.h" |
35 #include "net/http/http_transaction_factory.h" | 35 #include "net/http/http_transaction_factory.h" |
36 #include "net/http/http_util.h" | 36 #include "net/http/http_util.h" |
| 37 #include "net/proxy/proxy_info.h" |
37 #include "net/ssl/ssl_cert_request_info.h" | 38 #include "net/ssl/ssl_cert_request_info.h" |
38 #include "net/ssl/ssl_config_service.h" | 39 #include "net/ssl/ssl_config_service.h" |
39 #include "net/url_request/fraudulent_certificate_reporter.h" | 40 #include "net/url_request/fraudulent_certificate_reporter.h" |
40 #include "net/url_request/http_user_agent_settings.h" | 41 #include "net/url_request/http_user_agent_settings.h" |
41 #include "net/url_request/url_request.h" | 42 #include "net/url_request/url_request.h" |
42 #include "net/url_request/url_request_context.h" | 43 #include "net/url_request/url_request_context.h" |
43 #include "net/url_request/url_request_error_job.h" | 44 #include "net/url_request/url_request_error_job.h" |
44 #include "net/url_request/url_request_job_factory.h" | 45 #include "net/url_request/url_request_job_factory.h" |
45 #include "net/url_request/url_request_redirect_job.h" | 46 #include "net/url_request/url_request_redirect_job.h" |
46 #include "net/url_request/url_request_throttler_header_adapter.h" | 47 #include "net/url_request/url_request_throttler_header_adapter.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 280 |
280 void URLRequestHttpJob::Kill() { | 281 void URLRequestHttpJob::Kill() { |
281 if (!transaction_.get()) | 282 if (!transaction_.get()) |
282 return; | 283 return; |
283 | 284 |
284 weak_factory_.InvalidateWeakPtrs(); | 285 weak_factory_.InvalidateWeakPtrs(); |
285 DestroyTransaction(); | 286 DestroyTransaction(); |
286 URLRequestJob::Kill(); | 287 URLRequestJob::Kill(); |
287 } | 288 } |
288 | 289 |
| 290 void URLRequestHttpJob::NotifyBeforeSendProxyHeadersCallback( |
| 291 const ProxyInfo& proxy_info) { |
| 292 DCHECK_NE(URLRequestStatus::CANCELED, GetStatus().status()); |
| 293 if (network_delegate()) { |
| 294 network_delegate()->NotifyBeforeSendProxyHeaders( |
| 295 request_, |
| 296 proxy_info, |
| 297 &request_info_.extra_headers); |
| 298 } |
| 299 } |
| 300 |
289 void URLRequestHttpJob::NotifyHeadersComplete() { | 301 void URLRequestHttpJob::NotifyHeadersComplete() { |
290 DCHECK(!response_info_); | 302 DCHECK(!response_info_); |
291 | 303 |
292 response_info_ = transaction_->GetResponseInfo(); | 304 response_info_ = transaction_->GetResponseInfo(); |
293 | 305 |
294 // Save boolean, as we'll need this info at destruction time, and filters may | 306 // Save boolean, as we'll need this info at destruction time, and filters may |
295 // also need this info. | 307 // also need this info. |
296 is_cached_content_ = response_info_->was_cached; | 308 is_cached_content_ = response_info_->was_cached; |
297 | 309 |
298 if (!is_cached_content_ && throttling_entry_.get()) { | 310 if (!is_cached_content_ && throttling_entry_.get()) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 static_cast<WebSocketHandshakeStreamBase::CreateHelper*>(data)); | 435 static_cast<WebSocketHandshakeStreamBase::CreateHelper*>(data)); |
424 } else { | 436 } else { |
425 rv = ERR_DISALLOWED_URL_SCHEME; | 437 rv = ERR_DISALLOWED_URL_SCHEME; |
426 } | 438 } |
427 } | 439 } |
428 | 440 |
429 if (rv == OK) { | 441 if (rv == OK) { |
430 transaction_->SetBeforeNetworkStartCallback( | 442 transaction_->SetBeforeNetworkStartCallback( |
431 base::Bind(&URLRequestHttpJob::NotifyBeforeNetworkStart, | 443 base::Bind(&URLRequestHttpJob::NotifyBeforeNetworkStart, |
432 base::Unretained(this))); | 444 base::Unretained(this))); |
| 445 transaction_->SetBeforeProxyHeadersSentCallback( |
| 446 base::Bind(&URLRequestHttpJob::NotifyBeforeSendProxyHeadersCallback, |
| 447 base::Unretained(this))); |
433 | 448 |
434 if (!throttling_entry_.get() || | 449 if (!throttling_entry_.get() || |
435 !throttling_entry_->ShouldRejectRequest(*request_)) { | 450 !throttling_entry_->ShouldRejectRequest(*request_)) { |
436 rv = transaction_->Start( | 451 rv = transaction_->Start( |
437 &request_info_, start_callback_, request_->net_log()); | 452 &request_info_, start_callback_, request_->net_log()); |
438 start_time_ = base::TimeTicks::Now(); | 453 start_time_ = base::TimeTicks::Now(); |
439 } else { | 454 } else { |
440 // Special error code for the exponential back-off module. | 455 // Special error code for the exponential back-off module. |
441 rv = ERR_TEMPORARILY_THROTTLED; | 456 rv = ERR_TEMPORARILY_THROTTLED; |
442 } | 457 } |
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 return override_response_headers_.get() ? | 1520 return override_response_headers_.get() ? |
1506 override_response_headers_.get() : | 1521 override_response_headers_.get() : |
1507 transaction_->GetResponseInfo()->headers.get(); | 1522 transaction_->GetResponseInfo()->headers.get(); |
1508 } | 1523 } |
1509 | 1524 |
1510 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1525 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
1511 awaiting_callback_ = false; | 1526 awaiting_callback_ = false; |
1512 } | 1527 } |
1513 | 1528 |
1514 } // namespace net | 1529 } // namespace net |
OLD | NEW |