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 HttpServerResponseInfo(HttpStatusCode status_code); | |
pfeldman
2013/07/19 12:47:57
explicit
kkania
2013/07/19 15:28:36
Done.
| |
21 | |
22 static HttpServerResponseInfo For404(); | |
pfeldman
2013/07/19 12:47:57
CreateFor404 ?
kkania
2013/07/19 15:28:36
Done.
| |
23 static HttpServerResponseInfo For500(const std::string& message); | |
pfeldman
2013/07/19 12:47:57
CreateFor500 ?
kkania
2013/07/19 15:28:36
Done.
| |
24 | |
25 void AddHeader(const std::string& name, const std::string& value); | |
26 | |
27 // This also adds an appropriate Content-Length header. | |
28 void SetBody(const std::string& body, const std::string& content_type); | |
29 | |
30 std::string Serialize() const; | |
31 | |
32 private: | |
33 typedef std::vector<std::pair<std::string, std::string> > Headers; | |
34 | |
35 HttpStatusCode status_code_; | |
36 Headers headers_; | |
37 std::string body_; | |
38 }; | |
39 | |
40 } // namespace net | |
41 | |
42 #endif // NET_SERVER_HTTP_SERVER_RESPONSE_INFO_H_ | |
OLD | NEW |