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

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

Issue 181063006: Gets the peer address (if available) in server requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated commit message, minor CR fix. Created 6 years, 9 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') | net/socket/stream_listen_socket.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 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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 169
170 TEST_F(HttpServerTest, Request) { 170 TEST_F(HttpServerTest, Request) {
171 TestHttpClient client; 171 TestHttpClient client;
172 ASSERT_EQ(OK, client.ConnectAndWait(server_address_)); 172 ASSERT_EQ(OK, client.ConnectAndWait(server_address_));
173 client.Send("GET /test HTTP/1.1\r\n\r\n"); 173 client.Send("GET /test HTTP/1.1\r\n\r\n");
174 ASSERT_TRUE(RunUntilRequestsReceived(1)); 174 ASSERT_TRUE(RunUntilRequestsReceived(1));
175 ASSERT_EQ("GET", requests_[0].method); 175 ASSERT_EQ("GET", requests_[0].method);
176 ASSERT_EQ("/test", requests_[0].path); 176 ASSERT_EQ("/test", requests_[0].path);
177 ASSERT_EQ("", requests_[0].data); 177 ASSERT_EQ("", requests_[0].data);
178 ASSERT_EQ(0u, requests_[0].headers.size()); 178 ASSERT_EQ(0u, requests_[0].headers.size());
179 ASSERT_TRUE(StartsWithASCII(requests_[0].peer.ToString(), "127.0.0.1", true));
179 } 180 }
180 181
181 TEST_F(HttpServerTest, RequestWithHeaders) { 182 TEST_F(HttpServerTest, RequestWithHeaders) {
182 TestHttpClient client; 183 TestHttpClient client;
183 ASSERT_EQ(OK, client.ConnectAndWait(server_address_)); 184 ASSERT_EQ(OK, client.ConnectAndWait(server_address_));
184 const char* kHeaders[][3] = { 185 const char* kHeaders[][3] = {
185 {"Header", ": ", "1"}, 186 {"Header", ": ", "1"},
186 {"HeaderWithNoWhitespace", ":", "1"}, 187 {"HeaderWithNoWhitespace", ":", "1"},
187 {"HeaderWithWhitespace", " : \t ", "1 1 1 \t "}, 188 {"HeaderWithWhitespace", " : \t ", "1 1 1 \t "},
188 {"HeaderWithColon", ": ", "1:1"}, 189 {"HeaderWithColon", ": ", "1:1"},
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 client.Send("GET /test2 HTTP/1.1\r\n\r\n"); 311 client.Send("GET /test2 HTTP/1.1\r\n\r\n");
311 ASSERT_TRUE(RunUntilRequestsReceived(2)); 312 ASSERT_TRUE(RunUntilRequestsReceived(2));
312 ASSERT_EQ("/test2", requests_[1].path); 313 ASSERT_EQ("/test2", requests_[1].path);
313 314
314 client.Send("GET /test3 HTTP/1.1\r\n\r\n"); 315 client.Send("GET /test3 HTTP/1.1\r\n\r\n");
315 ASSERT_TRUE(RunUntilRequestsReceived(3)); 316 ASSERT_TRUE(RunUntilRequestsReceived(3));
316 ASSERT_EQ("/test3", requests_[2].path); 317 ASSERT_EQ("/test3", requests_[2].path);
317 } 318 }
318 319
319 } // namespace net 320 } // namespace net
OLDNEW
« no previous file with comments | « net/server/http_server_request_info.h ('k') | net/socket/stream_listen_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698