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

Side by Side Diff: net/server/http_server.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 | « no previous file | net/server/http_server_request_info.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/server/http_server.h" 5 #include "net/server/http_server.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 delegate_->OnWebSocketMessage(connection->id(), message); 126 delegate_->OnWebSocketMessage(connection->id(), message);
127 continue; 127 continue;
128 } 128 }
129 129
130 HttpServerRequestInfo request; 130 HttpServerRequestInfo request;
131 size_t pos = 0; 131 size_t pos = 0;
132 if (!ParseHeaders(connection, &request, &pos)) 132 if (!ParseHeaders(connection, &request, &pos))
133 break; 133 break;
134 134
135 // Sets peer address if exists.
136 socket->GetPeerAddress(&request.peer);
137
135 std::string connection_header = request.GetHeaderValue("connection"); 138 std::string connection_header = request.GetHeaderValue("connection");
136 if (connection_header == "Upgrade") { 139 if (connection_header == "Upgrade") {
137 connection->web_socket_.reset(WebSocket::CreateWebSocket(connection, 140 connection->web_socket_.reset(WebSocket::CreateWebSocket(connection,
138 request, 141 request,
139 &pos)); 142 &pos));
140 143
141 if (!connection->web_socket_.get()) // Not enough data was received. 144 if (!connection->web_socket_.get()) // Not enough data was received.
142 break; 145 break;
143 delegate_->OnWebSocketRequest(connection->id(), request); 146 delegate_->OnWebSocketRequest(connection->id(), request);
144 connection->Shift(pos); 147 connection->Shift(pos);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 324 }
322 325
323 HttpConnection* HttpServer::FindConnection(StreamListenSocket* socket) { 326 HttpConnection* HttpServer::FindConnection(StreamListenSocket* socket) {
324 SocketToConnectionMap::iterator it = socket_to_connection_.find(socket); 327 SocketToConnectionMap::iterator it = socket_to_connection_.find(socket);
325 if (it == socket_to_connection_.end()) 328 if (it == socket_to_connection_.end())
326 return NULL; 329 return NULL;
327 return it->second; 330 return it->second;
328 } 331 }
329 332
330 } // namespace net 333 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/server/http_server_request_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698