| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 if (!request->context() || | 36 if (!request->context() || |
| 37 !request->context()->http_transaction_factory()) { | 37 !request->context()->http_transaction_factory()) { |
| 38 NOTREACHED() << "requires a valid context"; | 38 NOTREACHED() << "requires a valid context"; |
| 39 return new URLRequestErrorJob(request, net::ERR_INVALID_ARGUMENT); | 39 return new URLRequestErrorJob(request, net::ERR_INVALID_ARGUMENT); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // We cache the value of the switch because this code path is hit on every | 42 // We cache the value of the switch because this code path is hit on every |
| 43 // network request. | 43 // network request. |
| 44 static const bool kForceHTTPS = | 44 static const bool kForceHTTPS = |
| 45 CommandLine().HasSwitch(switches::kForceHTTPS); | 45 CommandLine::ForCurrentProcess()->HasSwitch(switches::kForceHTTPS); |
| 46 if (kForceHTTPS && scheme != "https") | 46 if (kForceHTTPS && scheme != "https") |
| 47 return new URLRequestErrorJob(request, net::ERR_DISALLOWED_URL_SCHEME); | 47 return new URLRequestErrorJob(request, net::ERR_DISALLOWED_URL_SCHEME); |
| 48 | 48 |
| 49 return new URLRequestHttpJob(request); | 49 return new URLRequestHttpJob(request); |
| 50 } | 50 } |
| 51 | 51 |
| 52 URLRequestHttpJob::URLRequestHttpJob(URLRequest* request) | 52 URLRequestHttpJob::URLRequestHttpJob(URLRequest* request) |
| 53 : URLRequestJob(request), | 53 : URLRequestJob(request), |
| 54 transaction_(NULL), | 54 transaction_(NULL), |
| 55 response_info_(NULL), | 55 response_info_(NULL), |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 // we can just ignore this notification. | 378 // we can just ignore this notification. |
| 379 if (!transaction_.get()) | 379 if (!transaction_.get()) |
| 380 return; | 380 return; |
| 381 | 381 |
| 382 // Clear the IO_PENDING status | 382 // Clear the IO_PENDING status |
| 383 SetStatus(URLRequestStatus()); | 383 SetStatus(URLRequestStatus()); |
| 384 | 384 |
| 385 if (result == net::OK) { | 385 if (result == net::OK) { |
| 386 NotifyHeadersComplete(); | 386 NotifyHeadersComplete(); |
| 387 } else if (net::IsCertificateError(result) && | 387 } else if (net::IsCertificateError(result) && |
| 388 !CommandLine().HasSwitch(switches::kForceHTTPS)) { | 388 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 389 switches::kForceHTTPS)) { |
| 389 // We encountered an SSL certificate error. Ask our delegate to decide | 390 // We encountered an SSL certificate error. Ask our delegate to decide |
| 390 // what we should do. | 391 // what we should do. |
| 391 // TODO(wtc): also pass ssl_info.cert_status, or just pass the whole | 392 // TODO(wtc): also pass ssl_info.cert_status, or just pass the whole |
| 392 // ssl_info. | 393 // ssl_info. |
| 393 request_->delegate()->OnSSLCertificateError( | 394 request_->delegate()->OnSSLCertificateError( |
| 394 request_, result, transaction_->GetResponseInfo()->ssl_info.cert); | 395 request_, result, transaction_->GetResponseInfo()->ssl_info.cert); |
| 395 } else { | 396 } else { |
| 396 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); | 397 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, result)); |
| 397 } | 398 } |
| 398 } | 399 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 DCHECK(response_cookies_.empty()); | 546 DCHECK(response_cookies_.empty()); |
| 546 | 547 |
| 547 std::string name = "Set-Cookie"; | 548 std::string name = "Set-Cookie"; |
| 548 std::string value; | 549 std::string value; |
| 549 | 550 |
| 550 void* iter = NULL; | 551 void* iter = NULL; |
| 551 while (response_info_->headers->EnumerateHeader(&iter, name, &value)) | 552 while (response_info_->headers->EnumerateHeader(&iter, name, &value)) |
| 552 response_cookies_.push_back(value); | 553 response_cookies_.push_back(value); |
| 553 } | 554 } |
| 554 | 555 |
| OLD | NEW |