xref: /aosp_15_r20/external/cronet/net/server/http_server_request_info.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2011 The Chromium Authors
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 
8 #include <map>
9 #include <string>
10 
11 #include "net/base/ip_endpoint.h"
12 
13 namespace net {
14 
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:
21   HttpServerRequestInfo();
22   HttpServerRequestInfo(const HttpServerRequestInfo& other);
23   ~HttpServerRequestInfo();
24 
25   // Returns header value for given header name. |header_name| should be
26   // lower case.
27   std::string GetHeaderValue(const std::string& header_name) const;
28 
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 
35   // Request peer address.
36   IPEndPoint peer;
37 
38   // Request method.
39   std::string method;
40 
41   // Request line.
42   std::string path;
43 
44   // Request data.
45   std::string data;
46 
47   // A map of the names -> values for HTTP headers. These should always
48   // contain lower case field names.
49   using HeadersMap = std::map<std::string, std::string>;
50   HeadersMap headers;
51 };
52 
53 }  // namespace net
54 
55 #endif  // NET_SERVER_HTTP_SERVER_REQUEST_INFO_H_
56