Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(773)

Unified Diff: net/url_request/url_request_unittest.cc

Issue 6541021: Send fatal proxy errors to the network delegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_test_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_unittest.cc
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 35573edef15a690487ef6054a719296fd3cda4da..dcbaf81eac68e409350828a8dae127d882556c24 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -27,6 +27,7 @@
#include "net/base/cookie_monster.h"
#include "net/base/cookie_policy.h"
#include "net/base/load_flags.h"
+#include "net/base/mock_host_resolver.h"
#include "net/base/net_errors.h"
#include "net/base/net_log.h"
#include "net/base/net_log_unittest.h"
@@ -230,6 +231,37 @@ TEST_F(URLRequestTestHTTP, ProxyTunnelRedirectTest) {
}
}
+// This is the same as the previous test, but checks that the network delegate
+// registers the error.
+TEST_F(URLRequestTestHTTP, NetworkDelegateTunnelConnectionFailed) {
+ ASSERT_TRUE(test_server_.Start());
+
+ TestDelegate d;
+ {
+ net::URLRequest r(GURL("https://www.redirect.com/"), &d);
+ scoped_refptr<TestURLRequestContext> context(
+ new TestURLRequestContext(test_server_.host_port_pair().ToString()));
+ TestHttpNetworkDelegate network_delegate;
+ context->set_network_delegate(&network_delegate);
+ r.set_context(context);
+
+ r.Start();
+ EXPECT_TRUE(r.is_pending());
+
+ MessageLoop::current()->Run();
+
+ EXPECT_EQ(net::URLRequestStatus::FAILED, r.status().status());
+ EXPECT_EQ(net::ERR_TUNNEL_CONNECTION_FAILED, r.status().os_error());
+ EXPECT_EQ(1, d.response_started_count());
+ // We should not have followed the redirect.
+ EXPECT_EQ(0, d.received_redirect_count());
+
+ EXPECT_EQ(1, network_delegate.error_count());
+ EXPECT_EQ(net::ERR_TUNNEL_CONNECTION_FAILED,
+ network_delegate.last_os_error());
+ }
+}
+
// In this unit test, we're using the HTTPTestServer as a proxy server and
// issuing a CONNECT request with the magic host name "www.server-auth.com".
// The HTTPTestServer will return a 401 response, which we should balk at.
@@ -2348,6 +2380,34 @@ TEST_F(URLRequestTest, Identifiers) {
ASSERT_NE(req.identifier(), other_req.identifier());
}
+// Check that a failure to connect to the proxy is reported to the network
+// delegate.
+TEST_F(URLRequestTest, NetworkDelegateProxyError) {
+ TestDelegate d;
+ TestURLRequest req(GURL("http://example.com"), &d);
+ req.set_method("GET");
+
+ scoped_ptr<net::MockHostResolverBase> host_resolver(
+ new net::MockHostResolver);
+ host_resolver->rules()->AddSimulatedFailure("*");
+ scoped_refptr<TestURLRequestContext> context(
+ new TestURLRequestContext("myproxy:70", host_resolver.release()));
+ TestHttpNetworkDelegate network_delegate;
+ context->set_network_delegate(&network_delegate);
+ req.set_context(context);
+
+ req.Start();
+ MessageLoop::current()->Run();
+
+ // Check we see a failed request.
+ EXPECT_FALSE(req.status().is_success());
+ EXPECT_EQ(net::URLRequestStatus::FAILED, req.status().status());
+ EXPECT_EQ(net::ERR_PROXY_CONNECTION_FAILED, req.status().os_error());
+
+ EXPECT_EQ(1, network_delegate.error_count());
+ EXPECT_EQ(net::ERR_PROXY_CONNECTION_FAILED, network_delegate.last_os_error());
+}
+
class URLRequestTestFTP : public URLRequestTest {
public:
URLRequestTestFTP() : test_server_(net::TestServer::TYPE_FTP, FilePath()) {
« no previous file with comments | « net/url_request/url_request_test_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698