Avi Drissman | 6459548 | 2022-09-14 20:52:29 | [diff] [blame] | 1 | // Copyright 2011 The Chromium Authors |
pfeldman@chromium.org | 0569d86 | 2010-07-05 11:32:40 | [diff] [blame] | 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_REQUEST_INFO_H_ |
| 6 | #define NET_SERVER_HTTP_SERVER_REQUEST_INFO_H_ |
| 7 | |
erg@chromium.org | 5097dc8 | 2010-07-15 17:23:23 | [diff] [blame] | 8 | #include <map> |
tfarina@chromium.org | b6dbb0a | 2011-04-18 00:17:41 | [diff] [blame] | 9 | #include <string> |
| 10 | |
gunsch@chromium.org | 0cbc29bd | 2014-03-20 21:51:44 | [diff] [blame] | 11 | #include "net/base/ip_endpoint.h" |
| 12 | |
tfarina@chromium.org | b6dbb0a | 2011-04-18 00:17:41 | [diff] [blame] | 13 | namespace net { |
pfeldman@chromium.org | 0569d86 | 2010-07-05 11:32:40 | [diff] [blame] | 14 | |
pfeldman@chromium.org | 0569d86 | 2010-07-05 11:32:40 | [diff] [blame] | 15 | // Meta information about an HTTP request. |
| 16 | // This is geared toward servers in that it keeps a map of the headers and |
| 17 | // values rather than just a list of header strings (which net::HttpRequestInfo |
| 18 | // does). |
| 19 | class HttpServerRequestInfo { |
| 20 | public: |
erg@google.com | 1889dc1b | 2010-10-14 22:03:13 | [diff] [blame] | 21 | HttpServerRequestInfo(); |
vmpstr | acd23b7 | 2016-02-26 21:08:55 | [diff] [blame] | 22 | HttpServerRequestInfo(const HttpServerRequestInfo& other); |
erg@google.com | 1889dc1b | 2010-10-14 22:03:13 | [diff] [blame] | 23 | ~HttpServerRequestInfo(); |
pfeldman@chromium.org | 0569d86 | 2010-07-05 11:32:40 | [diff] [blame] | 24 | |
kkania@chromium.org | 7ab0ffdf | 2013-07-31 22:27:59 | [diff] [blame] | 25 | // Returns header value for given header name. |header_name| should be |
| 26 | // lower case. |
pfeldman@chromium.org | 86c6a0b5 | 2011-08-02 19:49:25 | [diff] [blame] | 27 | std::string GetHeaderValue(const std::string& header_name) const; |
| 28 | |
vkuzkokov@chromium.org | bbae90f | 2014-05-10 19:20:34 | [diff] [blame] | 29 | // Checks for item in comma-separated header value for given header name. |
| 30 | // Both |header_name| and |header_value| should be lower case. |
| 31 | bool HasHeaderValue( |
| 32 | const std::string& header_name, |
| 33 | const std::string& header_value) const; |
| 34 | |
gunsch@chromium.org | 0cbc29bd | 2014-03-20 21:51:44 | [diff] [blame] | 35 | // Request peer address. |
| 36 | IPEndPoint peer; |
| 37 | |
pfeldman@chromium.org | 0569d86 | 2010-07-05 11:32:40 | [diff] [blame] | 38 | // Request method. |
| 39 | std::string method; |
| 40 | |
| 41 | // Request line. |
| 42 | std::string path; |
| 43 | |
| 44 | // Request data. |
| 45 | std::string data; |
| 46 | |
kkania@chromium.org | 7ab0ffdf | 2013-07-31 22:27:59 | [diff] [blame] | 47 | // A map of the names -> values for HTTP headers. These should always |
| 48 | // contain lower case field names. |
David Benjamin | 3d11aad | 2019-12-02 18:11:45 | [diff] [blame] | 49 | using HeadersMap = std::map<std::string, std::string>; |
| 50 | HeadersMap headers; |
pfeldman@chromium.org | 0569d86 | 2010-07-05 11:32:40 | [diff] [blame] | 51 | }; |
| 52 | |
tfarina@chromium.org | b6dbb0a | 2011-04-18 00:17:41 | [diff] [blame] | 53 | } // namespace net |
| 54 | |
pfeldman@chromium.org | 0569d86 | 2010-07-05 11:32:40 | [diff] [blame] | 55 | #endif // NET_SERVER_HTTP_SERVER_REQUEST_INFO_H_ |