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

Unified Diff: net/http/http_cache_unittest.cc

Issue 6488010: Propagate the remote socket address to URLRequest and to ViewHostMsg_FrameNavigate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address eroman's comments 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
Index: net/http/http_cache_unittest.cc
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index bf8cb6bd27230be5f85aa33a83dbc4f4b371bc38..8d5fea46a48a736d1f5e25ff5d8277aebc6268d5 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) {

Powered by Google App Engine
This is Rietveld 408576698