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

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

Issue 265603002: Revert of 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
« no previous file with comments | « net/server/http_server_request_info.h ('k') | no next file » | 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 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);
212 ASSERT_TRUE(StartsWithASCII(GetRequest(0).peer.ToString(), 211 ASSERT_TRUE(StartsWithASCII(GetRequest(0).peer.ToString(),
213 "127.0.0.1", 212 "127.0.0.1",
214 true)); 213 true));
215 } 214 }
216 215
217 TEST_F(HttpServerTest, InvalidHttpVersion) {
218 TestHttpClient client;
219 ASSERT_EQ(OK, client.ConnectAndWait(server_address_));
220 client.Send("GET /test HTTP//1\r\n\r\n");
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
228 TEST_F(HttpServerTest, RequestWithHeaders) { 216 TEST_F(HttpServerTest, RequestWithHeaders) {
229 TestHttpClient client; 217 TestHttpClient client;
230 ASSERT_EQ(OK, client.ConnectAndWait(server_address_)); 218 ASSERT_EQ(OK, client.ConnectAndWait(server_address_));
231 const char* kHeaders[][3] = { 219 const char* kHeaders[][3] = {
232 {"Header", ": ", "1"}, 220 {"Header", ": ", "1"},
233 {"HeaderWithNoWhitespace", ":", "1"}, 221 {"HeaderWithNoWhitespace", ":", "1"},
234 {"HeaderWithWhitespace", " : \t ", "1 1 1 \t "}, 222 {"HeaderWithWhitespace", " : \t ", "1 1 1 \t "},
235 {"HeaderWithColon", ": ", "1:1"}, 223 {"HeaderWithColon", ": ", "1:1"},
236 {"EmptyHeader", ":", ""}, 224 {"EmptyHeader", ":", ""},
237 {"EmptyHeaderWithWhitespace", ": \t ", ""}, 225 {"EmptyHeaderWithWhitespace", ": \t ", ""},
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 393
406 ASSERT_EQ(client_connection_id, GetConnectionId(2)); 394 ASSERT_EQ(client_connection_id, GetConnectionId(2));
407 server_->Send200(client_connection_id, "Content for /test3", "text/plain"); 395 server_->Send200(client_connection_id, "Content for /test3", "text/plain");
408 std::string response3; 396 std::string response3;
409 ASSERT_TRUE(client.Read(&response3)); 397 ASSERT_TRUE(client.Read(&response3));
410 ASSERT_TRUE(StartsWithASCII(response3, "HTTP/1.1 200 OK", true)); 398 ASSERT_TRUE(StartsWithASCII(response3, "HTTP/1.1 200 OK", true));
411 ASSERT_TRUE(EndsWith(response3, "Content for /test3", true)); 399 ASSERT_TRUE(EndsWith(response3, "Content for /test3", true));
412 } 400 }
413 401
414 } // namespace net 402 } // namespace net
OLDNEW
« no previous file with comments | « 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