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

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: Diff upload failed 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
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_EQ("HTTP/1.1", requests_[0].proto);
180 ASSERT_TRUE(StartsWithASCII(requests_[0].peer.ToString(), "127.0.0.1", true));
179 } 181 }
180 182
181 TEST_F(HttpServerTest, RequestWithHeaders) { 183 TEST_F(HttpServerTest, RequestWithHeaders) {
182 TestHttpClient client; 184 TestHttpClient client;
183 ASSERT_EQ(OK, client.ConnectAndWait(server_address_)); 185 ASSERT_EQ(OK, client.ConnectAndWait(server_address_));
184 const char* kHeaders[][3] = { 186 const char* kHeaders[][3] = {
185 {"Header", ": ", "1"}, 187 {"Header", ": ", "1"},
186 {"HeaderWithNoWhitespace", ":", "1"}, 188 {"HeaderWithNoWhitespace", ":", "1"},
187 {"HeaderWithWhitespace", " : \t ", "1 1 1 \t "}, 189 {"HeaderWithWhitespace", " : \t ", "1 1 1 \t "},
188 {"HeaderWithColon", ": ", "1:1"}, 190 {"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"); 312 client.Send("GET /test2 HTTP/1.1\r\n\r\n");
311 ASSERT_TRUE(RunUntilRequestsReceived(2)); 313 ASSERT_TRUE(RunUntilRequestsReceived(2));
312 ASSERT_EQ("/test2", requests_[1].path); 314 ASSERT_EQ("/test2", requests_[1].path);
313 315
314 client.Send("GET /test3 HTTP/1.1\r\n\r\n"); 316 client.Send("GET /test3 HTTP/1.1\r\n\r\n");
315 ASSERT_TRUE(RunUntilRequestsReceived(3)); 317 ASSERT_TRUE(RunUntilRequestsReceived(3));
316 ASSERT_EQ("/test3", requests_[2].path); 318 ASSERT_EQ("/test3", requests_[2].path);
317 } 319 }
318 320
319 } // namespace net 321 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698