OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypa
ss_protocol.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypa
ss_protocol.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 TestDelegate d; | 238 TestDelegate d; |
239 std::unique_ptr<URLRequest> r(context_->CreateRequest( | 239 std::unique_ptr<URLRequest> r(context_->CreateRequest( |
240 GURL("http://www.google.com/"), net::DEFAULT_PRIORITY, &d)); | 240 GURL("http://www.google.com/"), net::DEFAULT_PRIORITY, &d)); |
241 r->set_method(method); | 241 r->set_method(method); |
242 r->SetLoadFlags(net::LOAD_NORMAL); | 242 r->SetLoadFlags(net::LOAD_NORMAL); |
243 | 243 |
244 r->Start(); | 244 r->Start(); |
245 base::RunLoop().Run(); | 245 base::RunLoop().Run(); |
246 | 246 |
247 if (!expected_error) { | 247 if (!expected_error) { |
248 EXPECT_EQ(net::URLRequestStatus::SUCCESS, r->status().status()); | 248 EXPECT_EQ(net::OK, d.request_status()); |
249 EXPECT_EQ(net::OK, r->status().error()); | |
250 if (expected_retry) | 249 if (expected_retry) |
251 EXPECT_EQ(initial_headers_received_count + 2, | 250 EXPECT_EQ(initial_headers_received_count + 2, |
252 network_delegate_->headers_received_count()); | 251 network_delegate_->headers_received_count()); |
253 else | 252 else |
254 EXPECT_EQ(initial_headers_received_count + 1, | 253 EXPECT_EQ(initial_headers_received_count + 1, |
255 network_delegate_->headers_received_count()); | 254 network_delegate_->headers_received_count()); |
256 EXPECT_EQ(content, d.data_received()); | 255 EXPECT_EQ(content, d.data_received()); |
257 return; | 256 return; |
258 } | 257 } |
259 EXPECT_EQ(net::URLRequestStatus::FAILED, r->status().status()); | 258 EXPECT_EQ(net::ERR_INVALID_RESPONSE, d.request_status()); |
260 EXPECT_EQ(net::ERR_INVALID_RESPONSE, r->status().error()); | |
261 EXPECT_EQ(initial_headers_received_count, | 259 EXPECT_EQ(initial_headers_received_count, |
262 network_delegate_->headers_received_count()); | 260 network_delegate_->headers_received_count()); |
263 } | 261 } |
264 | 262 |
265 // Returns the key to the |ProxyRetryInfoMap|. | 263 // Returns the key to the |ProxyRetryInfoMap|. |
266 std::string GetProxyKey(const std::string& proxy) { | 264 std::string GetProxyKey(const std::string& proxy) { |
267 net::ProxyServer proxy_server = net::ProxyServer::FromURI( | 265 net::ProxyServer proxy_server = net::ProxyServer::FromURI( |
268 proxy, net::ProxyServer::SCHEME_HTTP); | 266 proxy, net::ProxyServer::SCHEME_HTTP); |
269 if (!proxy_server.is_valid()) | 267 if (!proxy_server.is_valid()) |
270 return HostPortPair::FromURL(GURL(std::string())).ToString(); | 268 return HostPortPair::FromURL(GURL(std::string())).ToString(); |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 | 971 |
974 TestDelegate d; | 972 TestDelegate d; |
975 std::unique_ptr<URLRequest> r(context_->CreateRequest( | 973 std::unique_ptr<URLRequest> r(context_->CreateRequest( |
976 GURL("http://www.google.com/"), net::DEFAULT_PRIORITY, &d)); | 974 GURL("http://www.google.com/"), net::DEFAULT_PRIORITY, &d)); |
977 r->set_method("GET"); | 975 r->set_method("GET"); |
978 r->SetLoadFlags(net::LOAD_NORMAL); | 976 r->SetLoadFlags(net::LOAD_NORMAL); |
979 | 977 |
980 r->Start(); | 978 r->Start(); |
981 base::RunLoop().Run(); | 979 base::RunLoop().Run(); |
982 | 980 |
983 EXPECT_EQ(net::URLRequestStatus::SUCCESS, r->status().status()); | 981 EXPECT_EQ(net::OK, d.request_status()); |
984 EXPECT_EQ(net::OK, r->status().error()); | |
985 | 982 |
986 EXPECT_EQ("Bypass message", d.data_received()); | 983 EXPECT_EQ("Bypass message", d.data_received()); |
987 | 984 |
988 // We should have no entries in our bad proxy list. | 985 // We should have no entries in our bad proxy list. |
989 TestBadProxies(0, -1, "", ""); | 986 TestBadProxies(0, -1, "", ""); |
990 } | 987 } |
991 | 988 |
992 } // namespace data_reduction_proxy | 989 } // namespace data_reduction_proxy |
OLD | NEW |