[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 | |||||
14 | HttpServerRequestInfo::~HttpServerRequestInfo() {} | ||||
[email protected] | b6dbb0a | 2011-04-18 00:17:41 | [diff] [blame] | 15 | |
[email protected] | 86c6a0b5 | 2011-08-02 19:49:25 | [diff] [blame] | 16 | std::string HttpServerRequestInfo::GetHeaderValue( |
17 | const std::string& header_name) const { | ||||
brettw | 8e2106d | 2015-08-11 19:30:22 | [diff] [blame^] | 18 | DCHECK_EQ(base::ToLowerASCII(header_name), header_name); |
[email protected] | 86c6a0b5 | 2011-08-02 19:49:25 | [diff] [blame] | 19 | HttpServerRequestInfo::HeadersMap::const_iterator it = |
20 | headers.find(header_name); | ||||
21 | if (it != headers.end()) | ||||
22 | return it->second; | ||||
[email protected] | 007b3f8 | 2013-04-09 08:46:45 | [diff] [blame] | 23 | return std::string(); |
[email protected] | 86c6a0b5 | 2011-08-02 19:49:25 | [diff] [blame] | 24 | } |
25 | |||||
[email protected] | bbae90f | 2014-05-10 19:20:34 | [diff] [blame] | 26 | bool HttpServerRequestInfo::HasHeaderValue( |
27 | const std::string& header_name, | ||||
28 | const std::string& header_value) const { | ||||
brettw | 8e2106d | 2015-08-11 19:30:22 | [diff] [blame^] | 29 | DCHECK_EQ(base::ToLowerASCII(header_value), header_value); |
30 | std::string complete_value = base::ToLowerASCII(GetHeaderValue(header_name)); | ||||
brettw | 8cc24ae2 | 2015-07-06 23:53:00 | [diff] [blame] | 31 | |
32 | for (const base::StringPiece& cur : | ||||
33 | base::SplitString(complete_value, ",", base::KEEP_WHITESPACE, | ||||
34 | base::SPLIT_WANT_NONEMPTY)) { | ||||
35 | if (base::TrimString(cur, " \t", base::TRIM_ALL) == header_value) | ||||
[email protected] | bbae90f | 2014-05-10 19:20:34 | [diff] [blame] | 36 | return true; |
37 | } | ||||
38 | return false; | ||||
39 | } | ||||
40 | |||||
[email protected] | b6dbb0a | 2011-04-18 00:17:41 | [diff] [blame] | 41 | } // namespace net |