[email protected] | b6dbb0a | 2011-04-18 00:17:41 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 1889dc1b | 2010-10-14 22:03:13 | [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 | #include "net/server/http_server_request_info.h" | ||||
6 | |||||
brettw | 8cc24ae2 | 2015-07-06 23:53:00 | [diff] [blame] | 7 | #include "base/strings/string_split.h" |
[email protected] | 7ab0ffdf | 2013-07-31 22:27:59 | [diff] [blame] | 8 | #include "base/strings/string_util.h" |
9 | |||||
[email protected] | b6dbb0a | 2011-04-18 00:17:41 | [diff] [blame] | 10 | namespace net { |
11 | |||||
[email protected] | 1889dc1b | 2010-10-14 22:03:13 | [diff] [blame] | 12 | HttpServerRequestInfo::HttpServerRequestInfo() {} |
13 | |||||
vmpstr | acd23b7 | 2016-02-26 21:08:55 | [diff] [blame^] | 14 | HttpServerRequestInfo::HttpServerRequestInfo( |
15 | const HttpServerRequestInfo& other) = default; | ||||
16 | |||||
[email protected] | 1889dc1b | 2010-10-14 22:03:13 | [diff] [blame] | 17 | HttpServerRequestInfo::~HttpServerRequestInfo() {} |
[email protected] | b6dbb0a | 2011-04-18 00:17:41 | [diff] [blame] | 18 | |
[email protected] | 86c6a0b5 | 2011-08-02 19:49:25 | [diff] [blame] | 19 | std::string HttpServerRequestInfo::GetHeaderValue( |
20 | const std::string& header_name) const { | ||||
brettw | 8e2106d | 2015-08-11 19:30:22 | [diff] [blame] | 21 | DCHECK_EQ(base::ToLowerASCII(header_name), header_name); |
[email protected] | 86c6a0b5 | 2011-08-02 19:49:25 | [diff] [blame] | 22 | HttpServerRequestInfo::HeadersMap::const_iterator it = |
23 | headers.find(header_name); | ||||
24 | if (it != headers.end()) | ||||
25 | return it->second; | ||||
[email protected] | 007b3f8 | 2013-04-09 08:46:45 | [diff] [blame] | 26 | return std::string(); |
[email protected] | 86c6a0b5 | 2011-08-02 19:49:25 | [diff] [blame] | 27 | } |
28 | |||||
[email protected] | bbae90f | 2014-05-10 19:20:34 | [diff] [blame] | 29 | bool HttpServerRequestInfo::HasHeaderValue( |
30 | const std::string& header_name, | ||||
31 | const std::string& header_value) const { | ||||
brettw | 8e2106d | 2015-08-11 19:30:22 | [diff] [blame] | 32 | DCHECK_EQ(base::ToLowerASCII(header_value), header_value); |
33 | std::string complete_value = base::ToLowerASCII(GetHeaderValue(header_name)); | ||||
brettw | 8cc24ae2 | 2015-07-06 23:53:00 | [diff] [blame] | 34 | |
35 | for (const base::StringPiece& cur : | ||||
36 | base::SplitString(complete_value, ",", base::KEEP_WHITESPACE, | ||||
37 | base::SPLIT_WANT_NONEMPTY)) { | ||||
38 | if (base::TrimString(cur, " \t", base::TRIM_ALL) == header_value) | ||||
[email protected] | bbae90f | 2014-05-10 19:20:34 | [diff] [blame] | 39 | return true; |
40 | } | ||||
41 | return false; | ||||
42 | } | ||||
43 | |||||
[email protected] | b6dbb0a | 2011-04-18 00:17:41 | [diff] [blame] | 44 | } // namespace net |