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

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

Issue 251213004: HttpServer: avoid DCHECK'ing on non-HTTP/1.1 requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 TEST_F(HttpServerTest, Request) { 202 TEST_F(HttpServerTest, Request) {
203 TestHttpClient client; 203 TestHttpClient client;
204 ASSERT_EQ(OK, client.ConnectAndWait(server_address_)); 204 ASSERT_EQ(OK, client.ConnectAndWait(server_address_));
205 client.Send("GET /test HTTP/1.1\r\n\r\n"); 205 client.Send("GET /test HTTP/1.1\r\n\r\n");
206 ASSERT_TRUE(RunUntilRequestsReceived(1)); 206 ASSERT_TRUE(RunUntilRequestsReceived(1));
207 ASSERT_EQ("GET", GetRequest(0).method); 207 ASSERT_EQ("GET", GetRequest(0).method);
208 ASSERT_EQ("/test", GetRequest(0).path); 208 ASSERT_EQ("/test", GetRequest(0).path);
209 ASSERT_EQ("", GetRequest(0).data); 209 ASSERT_EQ("", GetRequest(0).data);
210 ASSERT_EQ(0u, GetRequest(0).headers.size()); 210 ASSERT_EQ(0u, GetRequest(0).headers.size());
211 ASSERT_EQ(HttpVersion(1, 1), GetRequest(0).http_version);
211 ASSERT_TRUE(StartsWithASCII(GetRequest(0).peer.ToString(), 212 ASSERT_TRUE(StartsWithASCII(GetRequest(0).peer.ToString(),
212 "127.0.0.1", 213 "127.0.0.1",
213 true)); 214 true));
214 } 215 }
215 216
217 TEST_F(HttpServerTest, InvalidHttpVersion) {
byungchul 2014/04/28 23:57:10 This test should go http_util_unittests.cc
gunsch 2014/04/29 00:02:32 No, this is about HttpServer replacing invalid hea
218 TestHttpClient client;
219 ASSERT_EQ(OK, client.ConnectAndWait(server_address_));
220 client.Send("GET /test HTTP//1\r\n\r\n");
byungchul 2014/04/28 23:57:10 HTTP/1.0 in real world.
gunsch 2014/04/29 00:02:32 HttpResponseHeadersTest has a test for replacing "
221 ASSERT_TRUE(RunUntilRequestsReceived(1));
222 ASSERT_EQ("GET", GetRequest(0).method);
223 ASSERT_EQ("/test", GetRequest(0).path);
224 ASSERT_EQ("", GetRequest(0).data);
225 ASSERT_EQ(HttpVersion(1, 0), GetRequest(0).http_version);
226 }
227
216 TEST_F(HttpServerTest, RequestWithHeaders) { 228 TEST_F(HttpServerTest, RequestWithHeaders) {
217 TestHttpClient client; 229 TestHttpClient client;
218 ASSERT_EQ(OK, client.ConnectAndWait(server_address_)); 230 ASSERT_EQ(OK, client.ConnectAndWait(server_address_));
219 const char* kHeaders[][3] = { 231 const char* kHeaders[][3] = {
220 {"Header", ": ", "1"}, 232 {"Header", ": ", "1"},
221 {"HeaderWithNoWhitespace", ":", "1"}, 233 {"HeaderWithNoWhitespace", ":", "1"},
222 {"HeaderWithWhitespace", " : \t ", "1 1 1 \t "}, 234 {"HeaderWithWhitespace", " : \t ", "1 1 1 \t "},
223 {"HeaderWithColon", ": ", "1:1"}, 235 {"HeaderWithColon", ": ", "1:1"},
224 {"EmptyHeader", ":", ""}, 236 {"EmptyHeader", ":", ""},
225 {"EmptyHeaderWithWhitespace", ": \t ", ""}, 237 {"EmptyHeaderWithWhitespace", ": \t ", ""},
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 405
394 ASSERT_EQ(client_connection_id, GetConnectionId(2)); 406 ASSERT_EQ(client_connection_id, GetConnectionId(2));
395 server_->Send200(client_connection_id, "Content for /test3", "text/plain"); 407 server_->Send200(client_connection_id, "Content for /test3", "text/plain");
396 std::string response3; 408 std::string response3;
397 ASSERT_TRUE(client.Read(&response3)); 409 ASSERT_TRUE(client.Read(&response3));
398 ASSERT_TRUE(StartsWithASCII(response3, "HTTP/1.1 200 OK", true)); 410 ASSERT_TRUE(StartsWithASCII(response3, "HTTP/1.1 200 OK", true));
399 ASSERT_TRUE(EndsWith(response3, "Content for /test3", true)); 411 ASSERT_TRUE(EndsWith(response3, "Content for /test3", true));
400 } 412 }
401 413
402 } // namespace net 414 } // namespace net
OLDNEW
« net/http/http_response_headers.cc ('K') | « net/server/http_server_request_info.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698