blob: 07c15a543534b04f4b478edce80099bc0f35ad00 [file] [log] [blame]
[email protected]b6dbb0a2011-04-18 00:17:411// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]1889dc1b2010-10-14 22:03:132// 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
brettw8cc24ae22015-07-06 23:53:007#include "base/strings/string_split.h"
[email protected]7ab0ffdf2013-07-31 22:27:598#include "base/strings/string_util.h"
9
[email protected]b6dbb0a2011-04-18 00:17:4110namespace net {
11
[email protected]1889dc1b2010-10-14 22:03:1312HttpServerRequestInfo::HttpServerRequestInfo() {}
13
14HttpServerRequestInfo::~HttpServerRequestInfo() {}
[email protected]b6dbb0a2011-04-18 00:17:4115
[email protected]86c6a0b52011-08-02 19:49:2516std::string HttpServerRequestInfo::GetHeaderValue(
17 const std::string& header_name) const {
brettw8e2106d2015-08-11 19:30:2218 DCHECK_EQ(base::ToLowerASCII(header_name), header_name);
[email protected]86c6a0b52011-08-02 19:49:2519 HttpServerRequestInfo::HeadersMap::const_iterator it =
20 headers.find(header_name);
21 if (it != headers.end())
22 return it->second;
[email protected]007b3f82013-04-09 08:46:4523 return std::string();
[email protected]86c6a0b52011-08-02 19:49:2524}
25
[email protected]bbae90f2014-05-10 19:20:3426bool HttpServerRequestInfo::HasHeaderValue(
27 const std::string& header_name,
28 const std::string& header_value) const {
brettw8e2106d2015-08-11 19:30:2229 DCHECK_EQ(base::ToLowerASCII(header_value), header_value);
30 std::string complete_value = base::ToLowerASCII(GetHeaderValue(header_name));
brettw8cc24ae22015-07-06 23:53:0031
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]bbae90f2014-05-10 19:20:3436 return true;
37 }
38 return false;
39}
40
[email protected]b6dbb0a2011-04-18 00:17:4141} // namespace net