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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 connection->Send(status_code, data, content_type); | 55 connection->Send(status_code, data, content_type); |
56 } | 56 } |
57 | 57 |
58 void HttpServer::Send200(int connection_id, | 58 void HttpServer::Send200(int connection_id, |
59 const std::string& data, | 59 const std::string& data, |
60 const std::string& content_type) { | 60 const std::string& content_type) { |
61 Send(connection_id, HTTP_OK, data, content_type); | 61 Send(connection_id, HTTP_OK, data, content_type); |
62 } | 62 } |
63 | 63 |
64 void HttpServer::Send404(int connection_id) { | 64 void HttpServer::Send404(int connection_id) { |
65 Send(connection_id, HTTP_NOT_FOUND, "", "text/html"); | 65 Send(connection_id, HTTP_NOT_FOUND, std::string(), "text/html"); |
66 } | 66 } |
67 | 67 |
68 void HttpServer::Send500(int connection_id, const std::string& message) { | 68 void HttpServer::Send500(int connection_id, const std::string& message) { |
69 Send(connection_id, HTTP_INTERNAL_SERVER_ERROR, message, "text/html"); | 69 Send(connection_id, HTTP_INTERNAL_SERVER_ERROR, message, "text/html"); |
70 } | 70 } |
71 | 71 |
72 void HttpServer::Close(int connection_id) { | 72 void HttpServer::Close(int connection_id) { |
73 HttpConnection* connection = FindConnection(connection_id); | 73 HttpConnection* connection = FindConnection(connection_id); |
74 if (connection == NULL) | 74 if (connection == NULL) |
75 return; | 75 return; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 } | 291 } |
292 | 292 |
293 HttpConnection* HttpServer::FindConnection(StreamListenSocket* socket) { | 293 HttpConnection* HttpServer::FindConnection(StreamListenSocket* socket) { |
294 SocketToConnectionMap::iterator it = socket_to_connection_.find(socket); | 294 SocketToConnectionMap::iterator it = socket_to_connection_.find(socket); |
295 if (it == socket_to_connection_.end()) | 295 if (it == socket_to_connection_.end()) |
296 return NULL; | 296 return NULL; |
297 return it->second; | 297 return it->second; |
298 } | 298 } |
299 | 299 |
300 } // namespace net | 300 } // namespace net |
OLD | NEW |