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

Side by Side Diff: net/http/http_response_headers_unittest.cc

Issue 10399083: Make NetLog take in callbacks that return Values (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix merge error Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_response_headers.cc ('k') | net/http/http_stream_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/pickle.h" 8 #include "base/pickle.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/values.h"
10 #include "net/http/http_response_headers.h" 11 #include "net/http/http_response_headers.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace { 14 namespace {
14 15
15 struct TestData { 16 struct TestData {
16 const char* raw_headers; 17 const char* raw_headers;
17 const char* expected_headers; 18 const char* expected_headers;
18 int expected_response_code; 19 int expected_response_code;
19 net::HttpVersion expected_parsed_version; 20 net::HttpVersion expected_parsed_version;
(...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 new net::HttpResponseHeaders(orig_headers)); 1750 new net::HttpResponseHeaders(orig_headers));
1750 1751
1751 std::string name(tests[i].new_status); 1752 std::string name(tests[i].new_status);
1752 parsed->ReplaceStatusLine(name); 1753 parsed->ReplaceStatusLine(name);
1753 1754
1754 std::string resulting_headers; 1755 std::string resulting_headers;
1755 parsed->GetNormalizedHeaders(&resulting_headers); 1756 parsed->GetNormalizedHeaders(&resulting_headers);
1756 EXPECT_EQ(std::string(tests[i].expected_headers), resulting_headers); 1757 EXPECT_EQ(std::string(tests[i].expected_headers), resulting_headers);
1757 } 1758 }
1758 } 1759 }
1760
1761 TEST(HttpResponseHeadersTest, ToNetLogParamAndBackAgain) {
1762 std::string headers("HTTP/1.1 404\n"
1763 "Content-Length: 450\n"
1764 "Connection: keep-alive\n");
1765 HeadersToRaw(&headers);
1766 scoped_refptr<net::HttpResponseHeaders> parsed(
1767 new net::HttpResponseHeaders(headers));
1768
1769 scoped_ptr<base::Value> event_param(
1770 parsed->NetLogCallback(net::NetLog::LOG_ALL_BUT_BYTES));
1771 scoped_refptr<net::HttpResponseHeaders> recreated;
1772
1773 ASSERT_TRUE(net::HttpResponseHeaders::FromNetLogParam(event_param.get(),
1774 &recreated));
1775 ASSERT_TRUE(recreated.get());
1776 EXPECT_EQ(parsed->GetHttpVersion(), recreated->GetHttpVersion());
1777 EXPECT_EQ(parsed->response_code(), recreated->response_code());
1778 EXPECT_EQ(parsed->GetContentLength(), recreated->GetContentLength());
1779 EXPECT_EQ(parsed->IsKeepAlive(), recreated->IsKeepAlive());
1780
1781 std::string normalized_parsed;
1782 parsed->GetNormalizedHeaders(&normalized_parsed);
1783 std::string normalized_recreated;
1784 parsed->GetNormalizedHeaders(&normalized_recreated);
1785 EXPECT_EQ(normalized_parsed, normalized_recreated);
1786 }
OLDNEW
« no previous file with comments | « net/http/http_response_headers.cc ('k') | net/http/http_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698