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

Unified Diff: net/server/http_server.cc

Issue 19637005: Allow HttpServer response to include custom headers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: net/server/http_server.cc
diff --git a/net/server/http_server.cc b/net/server/http_server.cc
index b78073983aed08b1e69400e51e2deb819dd39e6f..d4690ba411ede205d271c4c34a40b4a65d188115 100644
--- a/net/server/http_server.cc
+++ b/net/server/http_server.cc
@@ -11,8 +11,10 @@
#include "base/strings/stringprintf.h"
#include "base/sys_byteorder.h"
#include "build/build_config.h"
+#include "net/http/http_status_code.h"
#include "net/server/http_connection.h"
#include "net/server/http_server_request_info.h"
+#include "net/server/http_server_response_info.h"
#include "net/server/web_socket.h"
#include "net/socket/tcp_listen_socket.h"
@@ -46,27 +48,27 @@ void HttpServer::SendOverWebSocket(int connection_id,
}
void HttpServer::Send(int connection_id,
- HttpStatusCode status_code,
- const std::string& data,
- const std::string& content_type) {
+ const HttpServerResponseInfo& response) {
HttpConnection* connection = FindConnection(connection_id);
if (connection == NULL)
return;
- connection->Send(status_code, data, content_type);
+ connection->Send(response);
}
void HttpServer::Send200(int connection_id,
const std::string& data,
const std::string& content_type) {
- Send(connection_id, HTTP_OK, data, content_type);
+ HttpServerResponseInfo response(HTTP_OK);
+ response.SetBody(data, content_type);
+ Send(connection_id, response);
}
void HttpServer::Send404(int connection_id) {
- Send(connection_id, HTTP_NOT_FOUND, std::string(), "text/html");
+ Send(connection_id, HttpServerResponseInfo::CreateFor404());
}
void HttpServer::Send500(int connection_id, const std::string& message) {
- Send(connection_id, HTTP_INTERNAL_SERVER_ERROR, message, "text/html");
+ Send(connection_id, HttpServerResponseInfo::CreateFor500(message));
}
void HttpServer::Close(int connection_id) {

Powered by Google App Engine
This is Rietveld 408576698