| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 std::string raw_headers; | 69 std::string raw_headers; |
| 70 if (base::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 base::ReplaceSubstringsAfterOffset( |
| 80 &raw_headers, 0, "\n", base::StringPiece("\0", 1)); |
| 80 info->headers = new net::HttpResponseHeaders(raw_headers); | 81 info->headers = new net::HttpResponseHeaders(raw_headers); |
| 81 } | 82 } |
| 82 | 83 |
| 83 URLRequestAbortOnEndJob::URLRequestAbortOnEndJob( | 84 URLRequestAbortOnEndJob::URLRequestAbortOnEndJob( |
| 84 net::URLRequest* request, net::NetworkDelegate* network_delegate) | 85 net::URLRequest* request, net::NetworkDelegate* network_delegate) |
| 85 : URLRequestJob(request, network_delegate), | 86 : URLRequestJob(request, network_delegate), |
| 86 sent_data_(false), | 87 sent_data_(false), |
| 87 weak_factory_(this) { | 88 weak_factory_(this) { |
| 88 } | 89 } |
| 89 | 90 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 120 return true; | 121 return true; |
| 121 } | 122 } |
| 122 | 123 |
| 123 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED, | 124 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED, |
| 124 net::ERR_CONNECTION_ABORTED)); | 125 net::ERR_CONNECTION_ABORTED)); |
| 125 *bytes_read = -1; | 126 *bytes_read = -1; |
| 126 return false; | 127 return false; |
| 127 } | 128 } |
| 128 | 129 |
| 129 } // namespace content | 130 } // namespace content |
| OLD | NEW |