| 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 // This class simulates what wininet does when a dns lookup fails. | 4 // This class simulates what wininet does when a dns lookup fails. |
| 5 | 5 |
| 6 #include <algorithm> | 6 #include <algorithm> |
| 7 #include <cstring> | 7 #include <cstring> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 void URLRequestAbortOnEndJob::AddUrlHandler() { | 46 void URLRequestAbortOnEndJob::AddUrlHandler() { |
| 47 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 47 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 48 base::Bind(AddUrlHandlerOnIOThread)); | 48 base::Bind(AddUrlHandlerOnIOThread)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Private const version. | 51 // Private const version. |
| 52 void URLRequestAbortOnEndJob::GetResponseInfoConst( | 52 void URLRequestAbortOnEndJob::GetResponseInfoConst( |
| 53 net::HttpResponseInfo* info) const { | 53 net::HttpResponseInfo* info) const { |
| 54 // Send back mock headers. | 54 // Send back mock headers. |
| 55 std::string raw_headers; | 55 std::string raw_headers; |
| 56 if (LowerCaseEqualsASCII(k400AbortOnEndUrl, | 56 if (base::LowerCaseEqualsASCII(k400AbortOnEndUrl, |
| 57 request_->url().spec().c_str())) { | 57 request_->url().spec().c_str())) { |
| 58 raw_headers.append( | 58 raw_headers.append( |
| 59 "HTTP/1.1 400 This is not OK\n" | 59 "HTTP/1.1 400 This is not OK\n" |
| 60 "Content-type: text/plain\n"); | 60 "Content-type: text/plain\n"); |
| 61 } else { | 61 } else { |
| 62 NOTREACHED(); | 62 NOTREACHED(); |
| 63 } | 63 } |
| 64 // ParseRawHeaders expects \0 to end each header line. | 64 // ParseRawHeaders expects \0 to end each header line. |
| 65 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); | 65 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); |
| 66 info->headers = new net::HttpResponseHeaders(raw_headers); | 66 info->headers = new net::HttpResponseHeaders(raw_headers); |
| 67 } | 67 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 return true; | 107 return true; |
| 108 } | 108 } |
| 109 | 109 |
| 110 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED, | 110 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED, |
| 111 net::ERR_CONNECTION_ABORTED)); | 111 net::ERR_CONNECTION_ABORTED)); |
| 112 *bytes_read = -1; | 112 *bytes_read = -1; |
| 113 return false; | 113 return false; |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace content | 116 } // namespace content |
| OLD | NEW |