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

Unified Diff: net/http/http_cache_unittest.cc

Issue 2670013002: net: remove GetNormalizedHeaders() function (Closed)
Patch Set: remove verification Created 3 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 | « google_apis/gaia/gaia_auth_fetcher.cc ('k') | net/http/http_response_headers.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_unittest.cc
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index 635c15ca98b101b35f2087019bb9f5f31303ac18..9decfb88da8eb1baaf2df8a0216c82c3f4d68fdb 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -70,6 +70,31 @@ using CacheEntryStatus = HttpResponseInfo::CacheEntryStatus;
namespace {
+// Returns a simple text serialization of the given
+// |HttpResponseHeaders|. This is used by tests to verify that an
+// |HttpResponseHeaders| matches an expectation string.
+//
+// * One line per header, written as:
+// HEADER_NAME: HEADER_VALUE\n
+// * The original case of header names is preserved.
+// * Whitespace around head names/values is stripped.
+// * Repeated headers are not aggregated.
+// * Headers are listed in their original order.
+std::string ToSimpleString(const scoped_refptr<HttpResponseHeaders>& parsed) {
tfarina 2017/02/14 22:13:18 Sorry, I had to steal your function. Maybe we can
eroman 2017/02/16 20:37:35 Can you add a TODO explaining this is a duplicate
tfarina 2017/02/16 22:18:02 Done.
+ std::string result = parsed->GetStatusLine() + "\n";
+
+ size_t iter = 0;
+ std::string name;
+ std::string value;
+ while (parsed->EnumerateHeaderLines(&iter, &name, &value)) {
+ std::string new_line = name + ": " + value + "\n";
+
+ result += new_line;
+ }
+
+ return result;
+}
+
// Tests the load timing values of a request that goes through a
// MockNetworkTransaction.
void TestLoadTimingNetworkRequest(const LoadTimingInfo& load_timing_info) {
@@ -262,7 +287,7 @@ void RunTransactionTestWithResponse(HttpCache* cache,
std::string* response_headers) {
HttpResponseInfo response;
RunTransactionTestWithResponseInfo(cache, trans_info, &response);
- response.headers->GetNormalizedHeaders(response_headers);
+ *response_headers = ToSimpleString(response.headers);
}
void RunTransactionTestWithResponseAndGetTiming(
@@ -275,7 +300,7 @@ void RunTransactionTestWithResponseAndGetTiming(
RunTransactionTestBase(cache, trans_info, MockHttpRequest(trans_info),
&response, log, load_timing_info, nullptr, nullptr,
nullptr);
- response.headers->GetNormalizedHeaders(response_headers);
+ *response_headers = ToSimpleString(response.headers);
}
// This class provides a handler for kFastNoStoreGET_Transaction so that the
@@ -6734,13 +6759,10 @@ TEST(HttpCache, UpdatesRequestResponseTimeOn304) {
EXPECT_EQ(response_time.ToInternalValue(),
response.response_time.ToInternalValue());
- std::string headers;
- response.headers->GetNormalizedHeaders(&headers);
-
EXPECT_EQ("HTTP/1.1 200 OK\n"
"Date: Wed, 22 Jul 2009 03:15:26 GMT\n"
"Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n",
- headers);
+ ToSimpleString(response.headers));
RemoveMockTransaction(&mock_network_response);
}
« no previous file with comments | « google_apis/gaia/gaia_auth_fetcher.cc ('k') | net/http/http_response_headers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698