http_server_request_info.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (c) 2011 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. #ifndef NET_SERVER_HTTP_SERVER_REQUEST_INFO_H_
  5. #define NET_SERVER_HTTP_SERVER_REQUEST_INFO_H_
  6. #include <map>
  7. #include <string>
  8. #include "net/base/ip_endpoint.h"
  9. namespace net {
  10. // Meta information about an HTTP request.
  11. // This is geared toward servers in that it keeps a map of the headers and
  12. // values rather than just a list of header strings (which net::HttpRequestInfo
  13. // does).
  14. class HttpServerRequestInfo {
  15. public:
  16. HttpServerRequestInfo();
  17. HttpServerRequestInfo(const HttpServerRequestInfo& other);
  18. ~HttpServerRequestInfo();
  19. // Returns header value for given header name. |header_name| should be
  20. // lower case.
  21. std::string GetHeaderValue(const std::string& header_name) const;
  22. // Checks for item in comma-separated header value for given header name.
  23. // Both |header_name| and |header_value| should be lower case.
  24. bool HasHeaderValue(
  25. const std::string& header_name,
  26. const std::string& header_value) const;
  27. // Request peer address.
  28. IPEndPoint peer;
  29. // Request method.
  30. std::string method;
  31. // Request line.
  32. std::string path;
  33. // Request data.
  34. std::string data;
  35. // A map of the names -> values for HTTP headers. These should always
  36. // contain lower case field names.
  37. using HeadersMap = std::map<std::string, std::string>;
  38. HeadersMap headers;
  39. };
  40. } // namespace net
  41. #endif // NET_SERVER_HTTP_SERVER_REQUEST_INFO_H_