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

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

Issue 212683006: HttpServer: allows sending raw response data for nontypical responses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rsleevi review fixes 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 (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 29 matching lines...) Expand all
40 40
41 void HttpServer::SendOverWebSocket(int connection_id, 41 void HttpServer::SendOverWebSocket(int connection_id,
42 const std::string& data) { 42 const std::string& data) {
43 HttpConnection* connection = FindConnection(connection_id); 43 HttpConnection* connection = FindConnection(connection_id);
44 if (connection == NULL) 44 if (connection == NULL)
45 return; 45 return;
46 DCHECK(connection->web_socket_.get()); 46 DCHECK(connection->web_socket_.get());
47 connection->web_socket_->Send(data); 47 connection->web_socket_->Send(data);
48 } 48 }
49 49
50 void HttpServer::SendRaw(int connection_id, const std::string& data) {
51 HttpConnection* connection = FindConnection(connection_id);
52 if (connection == NULL)
53 return;
54 connection->Send(data);
55 }
56
50 void HttpServer::SendResponse(int connection_id, 57 void HttpServer::SendResponse(int connection_id,
51 const HttpServerResponseInfo& response) { 58 const HttpServerResponseInfo& response) {
52 HttpConnection* connection = FindConnection(connection_id); 59 HttpConnection* connection = FindConnection(connection_id);
53 if (connection == NULL) 60 if (connection == NULL)
54 return; 61 return;
55 connection->Send(response); 62 connection->Send(response);
56 } 63 }
57 64
58 void HttpServer::Send(int connection_id, 65 void HttpServer::Send(int connection_id,
59 HttpStatusCode status_code, 66 HttpStatusCode status_code,
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 331 }
325 332
326 HttpConnection* HttpServer::FindConnection(StreamListenSocket* socket) { 333 HttpConnection* HttpServer::FindConnection(StreamListenSocket* socket) {
327 SocketToConnectionMap::iterator it = socket_to_connection_.find(socket); 334 SocketToConnectionMap::iterator it = socket_to_connection_.find(socket);
328 if (it == socket_to_connection_.end()) 335 if (it == socket_to_connection_.end())
329 return NULL; 336 return NULL;
330 return it->second; 337 return it->second;
331 } 338 }
332 339
333 } // namespace net 340 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698