Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_SERVER_HTTP_SERVER_RESPONSE_INFO_H_ | |
| 6 #define NET_SERVER_HTTP_SERVER_RESPONSE_INFO_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <utility> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "net/http/http_status_code.h" | |
| 13 | |
| 14 namespace net { | |
| 15 | |
| 16 class HttpServerResponseInfo { | |
| 17 public: | |
| 18 // Creates a 200 OK HttpServerResponseInfo. | |
| 19 HttpServerResponseInfo(); | |
| 20 explicit HttpServerResponseInfo(HttpStatusCode status_code); | |
| 21 ~HttpServerResponseInfo(); | |
| 22 | |
| 23 static HttpServerResponseInfo CreateFor404(); | |
| 24 static HttpServerResponseInfo CreateFor500(const std::string& message); | |
|
mmenke
2013/07/19 16:17:44
nit: This should be "body", not "message".
| |
| 25 | |
| 26 void AddHeader(const std::string& name, const std::string& value); | |
| 27 | |
| 28 // This also adds an appropriate Content-Length header. | |
| 29 void SetBody(const std::string& body, const std::string& content_type); | |
| 30 | |
| 31 std::string Serialize() const; | |
| 32 | |
| 33 private: | |
| 34 typedef std::vector<std::pair<std::string, std::string> > Headers; | |
| 35 | |
| 36 HttpStatusCode status_code_; | |
| 37 Headers headers_; | |
| 38 std::string body_; | |
| 39 }; | |
| 40 | |
| 41 } // namespace net | |
| 42 | |
| 43 #endif // NET_SERVER_HTTP_SERVER_RESPONSE_INFO_H_ | |
| OLD | NEW |