diff options
author | bryner@chromium.org <bryner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-22 19:47:19 +0000 |
---|---|---|
committer | bryner@chromium.org <bryner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-22 19:47:19 +0000 |
commit | 6d81b488e8cc5e10eaeca0a4ee4819dc3f469a24 (patch) | |
tree | e628aa40ac26d26a6a9a46374001be983e7a7f41 /net/http/http_cache_unittest.cc | |
parent | f19572134235f4cceb76e85e1c064ba668bbd3bd (diff) | |
download | chromium_src-6d81b488e8cc5e10eaeca0a4ee4819dc3f469a24.zip chromium_src-6d81b488e8cc5e10eaeca0a4ee4819dc3f469a24.tar.gz chromium_src-6d81b488e8cc5e10eaeca0a4ee4819dc3f469a24.tar.bz2 |
Propagate the remote socket address to URLRequest and to ViewHostMsg_FrameNavigate.
This will be used to run pre-classification checks for client-side phishing
detection, and will also enable the socket address to be exposed via the
webRequest extension API. This is adapted from the original patch by pmarks
on http://codereview.chromium.org/6369003/ .
BUG=51663
TEST=added socket address checks to various unittests
Review URL: http://codereview.chromium.org/6488010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75620 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_cache_unittest.cc')
-rw-r--r-- | net/http/http_cache_unittest.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index bf8cb6b..8d5fea4 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -11,6 +11,7 @@ #include "base/stringprintf.h" #include "net/base/cache_type.h" #include "net/base/cert_status_flags.h" +#include "net/base/host_port_pair.h" #include "net/base/load_flags.h" #include "net/base/net_errors.h" #include "net/base/net_log_unittest.h" @@ -3978,6 +3979,31 @@ TEST(HttpCache, WriteResponseInfo_Truncated) { entry->Close(); } +// Tests basic pickling/unpickling of HttpResponseInfo. +TEST(HttpCache, PersistHttpResponseInfo) { + // Set some fields (add more if needed.) + net::HttpResponseInfo response1; + response1.was_cached = false; + response1.socket_address = net::HostPortPair("1.2.3.4", 80); + response1.headers = new net::HttpResponseHeaders("HTTP/1.1 200 OK"); + + // Pickle. + Pickle pickle; + response1.Persist(&pickle, false, false); + + // Unpickle. + net::HttpResponseInfo response2; + bool response_truncated; + EXPECT_TRUE(response2.InitFromPickle(pickle, &response_truncated)); + EXPECT_FALSE(response_truncated); + + // Verify fields. + EXPECT_TRUE(response2.was_cached); // InitFromPickle sets this flag. + EXPECT_EQ("1.2.3.4", response2.socket_address.host()); + EXPECT_EQ(80, response2.socket_address.port()); + EXPECT_EQ("HTTP/1.1 200 OK", response2.headers->GetStatusLine()); +} + // Tests that we delete an entry when the request is cancelled before starting // to read from the network. TEST(HttpCache, DoomOnDestruction) { |