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

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

Issue 164304: Http cache: Extend support for byte range requests.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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/partial_data.h » ('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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 "net/http/http_response_headers.h" 10 #include "net/http/http_response_headers.h"
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 new HttpResponseHeaders(orig_headers); 1497 new HttpResponseHeaders(orig_headers);
1498 1498
1499 string name(tests[i].to_remove); 1499 string name(tests[i].to_remove);
1500 parsed->RemoveHeader(name); 1500 parsed->RemoveHeader(name);
1501 1501
1502 string resulting_headers; 1502 string resulting_headers;
1503 parsed->GetNormalizedHeaders(&resulting_headers); 1503 parsed->GetNormalizedHeaders(&resulting_headers);
1504 EXPECT_EQ(string(tests[i].expected_headers), resulting_headers); 1504 EXPECT_EQ(string(tests[i].expected_headers), resulting_headers);
1505 } 1505 }
1506 } 1506 }
1507
1508 TEST(HttpResponseHeadersTest, ReplaceStatus) {
1509 const struct {
1510 const char* orig_headers;
1511 const char* new_status;
1512 const char* expected_headers;
1513 } tests[] = {
1514 { "HTTP/1.1 206 Partial Content\n"
1515 "connection: keep-alive\n"
1516 "Cache-control: max-age=10000\n"
1517 "Content-Length: 450\n",
1518
1519 "HTTP/1.1 200 OK",
1520
1521 "HTTP/1.1 200 OK\n"
1522 "connection: keep-alive\n"
1523 "Cache-control: max-age=10000\n"
1524 "Content-Length: 450\n"
1525 },
1526 { "HTTP/1.1 200 OK\n"
1527 "connection: keep-alive\n",
1528
1529 "HTTP/1.1 304 Not Modified",
1530
1531 "HTTP/1.1 304 Not Modified\n"
1532 "connection: keep-alive\n"
1533 },
1534 { "HTTP/1.1 200 OK\n"
1535 "connection: keep-alive \n"
1536 "Content-Length : 450 \n"
1537 "Cache-control: max-age=10000\n",
1538
1539 "HTTP/1//1 304 Not Modified",
1540
1541 "HTTP/1.0 304 Not Modified\n"
1542 "connection: keep-alive\n"
1543 "Content-Length: 450\n"
1544 "Cache-control: max-age=10000\n"
1545 },
1546 };
1547
1548 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
1549 string orig_headers(tests[i].orig_headers);
1550 HeadersToRaw(&orig_headers);
1551 scoped_refptr<HttpResponseHeaders> parsed =
1552 new HttpResponseHeaders(orig_headers);
1553
1554 string name(tests[i].new_status);
1555 parsed->ReplaceStatusLine(name);
1556
1557 string resulting_headers;
1558 parsed->GetNormalizedHeaders(&resulting_headers);
1559 EXPECT_EQ(string(tests[i].expected_headers), resulting_headers);
1560 }
1561 }
OLDNEW
« no previous file with comments | « net/http/http_response_headers.cc ('k') | net/http/partial_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698