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/location.h" | 10 #include "base/location.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 void URLRequestAbortOnEndJob::AddUrlHandler() { | 60 void URLRequestAbortOnEndJob::AddUrlHandler() { |
61 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 61 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
62 base::Bind(AddUrlHandlerOnIOThread)); | 62 base::Bind(AddUrlHandlerOnIOThread)); |
63 } | 63 } |
64 | 64 |
65 // Private const version. | 65 // Private const version. |
66 void URLRequestAbortOnEndJob::GetResponseInfoConst( | 66 void URLRequestAbortOnEndJob::GetResponseInfoConst( |
67 net::HttpResponseInfo* info) const { | 67 net::HttpResponseInfo* info) const { |
68 // Send back mock headers. | 68 // Send back mock headers. |
69 std::string raw_headers; | 69 std::string raw_headers; |
70 if (LowerCaseEqualsASCII(k400AbortOnEndUrl, | 70 if (base::LowerCaseEqualsASCII(k400AbortOnEndUrl, |
71 request_->url().spec().c_str())) { | 71 request_->url().spec().c_str())) { |
72 raw_headers.append( | 72 raw_headers.append( |
73 "HTTP/1.1 400 This is not OK\n" | 73 "HTTP/1.1 400 This is not OK\n" |
74 "Content-type: text/plain\n"); | 74 "Content-type: text/plain\n"); |
75 } else { | 75 } else { |
76 NOTREACHED(); | 76 NOTREACHED(); |
77 } | 77 } |
78 // ParseRawHeaders expects \0 to end each header line. | 78 // ParseRawHeaders expects \0 to end each header line. |
79 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); | 79 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); |
80 info->headers = new net::HttpResponseHeaders(raw_headers); | 80 info->headers = new net::HttpResponseHeaders(raw_headers); |
81 } | 81 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 return true; | 120 return true; |
121 } | 121 } |
122 | 122 |
123 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED, | 123 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED, |
124 net::ERR_CONNECTION_ABORTED)); | 124 net::ERR_CONNECTION_ABORTED)); |
125 *bytes_read = -1; | 125 *bytes_read = -1; |
126 return false; | 126 return false; |
127 } | 127 } |
128 | 128 |
129 } // namespace content | 129 } // namespace content |
OLD | NEW |