Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/test/url_request/url_request_hanging_read_job.h" | 5 #include "net/test/url_request/url_request_hanging_read_job.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 raw_headers.append( | 85 raw_headers.append( |
| 86 "HTTP/1.1 200 OK\n" | 86 "HTTP/1.1 200 OK\n" |
| 87 "Content-type: text/plain\n"); | 87 "Content-type: text/plain\n"); |
| 88 raw_headers.append( | 88 raw_headers.append( |
| 89 base::StringPrintf("Content-Length: %1d\n", content_length_)); | 89 base::StringPrintf("Content-Length: %1d\n", content_length_)); |
| 90 info->headers = new HttpResponseHeaders(HttpUtil::AssembleRawHeaders( | 90 info->headers = new HttpResponseHeaders(HttpUtil::AssembleRawHeaders( |
| 91 raw_headers.c_str(), static_cast<int>(raw_headers.length()))); | 91 raw_headers.c_str(), static_cast<int>(raw_headers.length()))); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void URLRequestHangingReadJob::StartAsync() { | 94 void URLRequestHangingReadJob::StartAsync() { |
| 95 if (is_done()) | |
|
estark
2016/12/21 20:02:59
This is a little weird. I added it because CertNet
| |
| 96 return; | |
| 95 set_expected_content_size(content_length_); | 97 set_expected_content_size(content_length_); |
| 96 NotifyHeadersComplete(); | 98 NotifyHeadersComplete(); |
| 97 } | 99 } |
| 98 | 100 |
| 99 // static | 101 // static |
| 100 void URLRequestHangingReadJob::AddUrlHandler() { | 102 void URLRequestHangingReadJob::AddUrlHandler() { |
| 101 // Add |hostname| to URLRequestFilter for HTTP and HTTPS. | 103 // Add |hostname| to URLRequestFilter for HTTP and HTTPS. |
| 102 URLRequestFilter* filter = URLRequestFilter::GetInstance(); | 104 URLRequestFilter* filter = URLRequestFilter::GetInstance(); |
| 103 filter->AddHostnameInterceptor("http", kMockHostname, | 105 filter->AddHostnameInterceptor("http", kMockHostname, |
| 104 base::MakeUnique<MockJobInterceptor>()); | 106 base::MakeUnique<MockJobInterceptor>()); |
| 105 filter->AddHostnameInterceptor("https", kMockHostname, | 107 filter->AddHostnameInterceptor("https", kMockHostname, |
| 106 base::MakeUnique<MockJobInterceptor>()); | 108 base::MakeUnique<MockJobInterceptor>()); |
| 107 } | 109 } |
| 108 | 110 |
| 109 // static | 111 // static |
| 110 GURL URLRequestHangingReadJob::GetMockHttpUrl() { | 112 GURL URLRequestHangingReadJob::GetMockHttpUrl() { |
| 111 return GetMockUrl("http", kMockHostname); | 113 return GetMockUrl("http", kMockHostname); |
| 112 } | 114 } |
| 113 | 115 |
| 114 // static | 116 // static |
| 115 GURL URLRequestHangingReadJob::GetMockHttpsUrl() { | 117 GURL URLRequestHangingReadJob::GetMockHttpsUrl() { |
| 116 return GetMockUrl("https", kMockHostname); | 118 return GetMockUrl("https", kMockHostname); |
| 117 } | 119 } |
| 118 | 120 |
| 119 } // namespace net | 121 } // namespace net |
| OLD | NEW |