OLD | NEW |
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/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 connection->Send404(); | 76 connection->Send404(); |
77 } | 77 } |
78 | 78 |
79 void HttpServer::Send500(int connection_id, const std::string& message) { | 79 void HttpServer::Send500(int connection_id, const std::string& message) { |
80 HttpConnection* connection = FindConnection(connection_id); | 80 HttpConnection* connection = FindConnection(connection_id); |
81 if (connection == NULL) | 81 if (connection == NULL) |
82 return; | 82 return; |
83 connection->Send500(message); | 83 connection->Send500(message); |
84 } | 84 } |
85 | 85 |
86 void HttpServer::Close(int connection_id) | 86 void HttpServer::Close(int connection_id) { |
87 { | |
88 HttpConnection* connection = FindConnection(connection_id); | 87 HttpConnection* connection = FindConnection(connection_id); |
89 if (connection == NULL) | 88 if (connection == NULL) |
90 return; | 89 return; |
91 | 90 |
92 // Initiating close from server-side does not lead to the DidClose call. | 91 // Initiating close from server-side does not lead to the DidClose call. |
93 // Do it manually here. | 92 // Do it manually here. |
94 DidClose(connection->socket_); | 93 DidClose(connection->socket_); |
95 } | 94 } |
96 | 95 |
| 96 int HttpServer::GetLocalAddress(IPEndPoint* address) { |
| 97 return server_->GetLocalAddress(address); |
| 98 } |
| 99 |
97 void HttpServer::DidAccept(StreamListenSocket* server, | 100 void HttpServer::DidAccept(StreamListenSocket* server, |
98 StreamListenSocket* socket) { | 101 StreamListenSocket* socket) { |
99 HttpConnection* connection = new HttpConnection(this, socket); | 102 HttpConnection* connection = new HttpConnection(this, socket); |
100 id_to_connection_[connection->id()] = connection; | 103 id_to_connection_[connection->id()] = connection; |
101 socket_to_connection_[socket] = connection; | 104 socket_to_connection_[socket] = connection; |
102 } | 105 } |
103 | 106 |
104 void HttpServer::DidRead(StreamListenSocket* socket, | 107 void HttpServer::DidRead(StreamListenSocket* socket, |
105 const char* data, | 108 const char* data, |
106 int len) { | 109 int len) { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 } | 305 } |
303 | 306 |
304 HttpConnection* HttpServer::FindConnection(StreamListenSocket* socket) { | 307 HttpConnection* HttpServer::FindConnection(StreamListenSocket* socket) { |
305 SocketToConnectionMap::iterator it = socket_to_connection_.find(socket); | 308 SocketToConnectionMap::iterator it = socket_to_connection_.find(socket); |
306 if (it == socket_to_connection_.end()) | 309 if (it == socket_to_connection_.end()) |
307 return NULL; | 310 return NULL; |
308 return it->second; | 311 return it->second; |
309 } | 312 } |
310 | 313 |
311 } // namespace net | 314 } // namespace net |
OLD | NEW |