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

Side by Side Diff: net/server/http_server_unittest.cc

Issue 448853002: Move StringToLowerASCII to base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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/server/http_server_request_info.cc ('k') | net/spdy/hpack_huffman_aggregator.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <utility> 5 #include <utility>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 for (size_t i = 0; i < arraysize(kHeaders); ++i) { 255 for (size_t i = 0; i < arraysize(kHeaders); ++i) {
256 headers += 256 headers +=
257 std::string(kHeaders[i][0]) + kHeaders[i][1] + kHeaders[i][2] + "\r\n"; 257 std::string(kHeaders[i][0]) + kHeaders[i][1] + kHeaders[i][2] + "\r\n";
258 } 258 }
259 259
260 client.Send("GET /test HTTP/1.1\r\n" + headers + "\r\n"); 260 client.Send("GET /test HTTP/1.1\r\n" + headers + "\r\n");
261 ASSERT_TRUE(RunUntilRequestsReceived(1)); 261 ASSERT_TRUE(RunUntilRequestsReceived(1));
262 ASSERT_EQ("", GetRequest(0).data); 262 ASSERT_EQ("", GetRequest(0).data);
263 263
264 for (size_t i = 0; i < arraysize(kHeaders); ++i) { 264 for (size_t i = 0; i < arraysize(kHeaders); ++i) {
265 std::string field = StringToLowerASCII(std::string(kHeaders[i][0])); 265 std::string field = base::StringToLowerASCII(std::string(kHeaders[i][0]));
266 std::string value = kHeaders[i][2]; 266 std::string value = kHeaders[i][2];
267 ASSERT_EQ(1u, GetRequest(0).headers.count(field)) << field; 267 ASSERT_EQ(1u, GetRequest(0).headers.count(field)) << field;
268 ASSERT_EQ(value, GetRequest(0).headers[field]) << kHeaders[i][0]; 268 ASSERT_EQ(value, GetRequest(0).headers[field]) << kHeaders[i][0];
269 } 269 }
270 } 270 }
271 271
272 TEST_F(HttpServerTest, RequestWithDuplicateHeaders) { 272 TEST_F(HttpServerTest, RequestWithDuplicateHeaders) {
273 TestHttpClient client; 273 TestHttpClient client;
274 ASSERT_EQ(OK, client.ConnectAndWait(server_address_)); 274 ASSERT_EQ(OK, client.ConnectAndWait(server_address_));
275 const char* kHeaders[][3] = { 275 const char* kHeaders[][3] = {
276 {"FirstHeader", ": ", "1"}, 276 {"FirstHeader", ": ", "1"},
277 {"DuplicateHeader", ": ", "2"}, 277 {"DuplicateHeader", ": ", "2"},
278 {"MiddleHeader", ": ", "3"}, 278 {"MiddleHeader", ": ", "3"},
279 {"DuplicateHeader", ": ", "4"}, 279 {"DuplicateHeader", ": ", "4"},
280 {"LastHeader", ": ", "5"}, 280 {"LastHeader", ": ", "5"},
281 }; 281 };
282 std::string headers; 282 std::string headers;
283 for (size_t i = 0; i < arraysize(kHeaders); ++i) { 283 for (size_t i = 0; i < arraysize(kHeaders); ++i) {
284 headers += 284 headers +=
285 std::string(kHeaders[i][0]) + kHeaders[i][1] + kHeaders[i][2] + "\r\n"; 285 std::string(kHeaders[i][0]) + kHeaders[i][1] + kHeaders[i][2] + "\r\n";
286 } 286 }
287 287
288 client.Send("GET /test HTTP/1.1\r\n" + headers + "\r\n"); 288 client.Send("GET /test HTTP/1.1\r\n" + headers + "\r\n");
289 ASSERT_TRUE(RunUntilRequestsReceived(1)); 289 ASSERT_TRUE(RunUntilRequestsReceived(1));
290 ASSERT_EQ("", GetRequest(0).data); 290 ASSERT_EQ("", GetRequest(0).data);
291 291
292 for (size_t i = 0; i < arraysize(kHeaders); ++i) { 292 for (size_t i = 0; i < arraysize(kHeaders); ++i) {
293 std::string field = StringToLowerASCII(std::string(kHeaders[i][0])); 293 std::string field = base::StringToLowerASCII(std::string(kHeaders[i][0]));
294 std::string value = (field == "duplicateheader") ? "2,4" : kHeaders[i][2]; 294 std::string value = (field == "duplicateheader") ? "2,4" : kHeaders[i][2];
295 ASSERT_EQ(1u, GetRequest(0).headers.count(field)) << field; 295 ASSERT_EQ(1u, GetRequest(0).headers.count(field)) << field;
296 ASSERT_EQ(value, GetRequest(0).headers[field]) << kHeaders[i][0]; 296 ASSERT_EQ(value, GetRequest(0).headers[field]) << kHeaders[i][0];
297 } 297 }
298 } 298 }
299 299
300 TEST_F(HttpServerTest, HasHeaderValueTest) { 300 TEST_F(HttpServerTest, HasHeaderValueTest) {
301 TestHttpClient client; 301 TestHttpClient client;
302 ASSERT_EQ(OK, client.ConnectAndWait(server_address_)); 302 ASSERT_EQ(OK, client.ConnectAndWait(server_address_));
303 const char* kHeaders[] = { 303 const char* kHeaders[] = {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 497
498 ASSERT_EQ(client_connection_id, GetConnectionId(2)); 498 ASSERT_EQ(client_connection_id, GetConnectionId(2));
499 server_->Send200(client_connection_id, "Content for /test3", "text/plain"); 499 server_->Send200(client_connection_id, "Content for /test3", "text/plain");
500 std::string response3; 500 std::string response3;
501 ASSERT_TRUE(client.Read(&response3)); 501 ASSERT_TRUE(client.Read(&response3));
502 ASSERT_TRUE(StartsWithASCII(response3, "HTTP/1.1 200 OK", true)); 502 ASSERT_TRUE(StartsWithASCII(response3, "HTTP/1.1 200 OK", true));
503 ASSERT_TRUE(EndsWith(response3, "Content for /test3", true)); 503 ASSERT_TRUE(EndsWith(response3, "Content for /test3", true));
504 } 504 }
505 505
506 } // namespace net 506 } // namespace net
OLDNEW
« no previous file with comments | « net/server/http_server_request_info.cc ('k') | net/spdy/hpack_huffman_aggregator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698