blob: 58021cf29e50db0dbd6ace1bb96021a6cdd102fb [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
Chris Watkins7a41d3552017-12-01 02:13:2712HttpServerRequestInfo::HttpServerRequestInfo() = default;
[email protected]1889dc1b2010-10-14 22:03:1313
vmpstracd23b72016-02-26 21:08:5514HttpServerRequestInfo::HttpServerRequestInfo(
15 const HttpServerRequestInfo& other) = default;
16
Chris Watkins7a41d3552017-12-01 02:13:2717HttpServerRequestInfo::~HttpServerRequestInfo() = default;
[email protected]b6dbb0a2011-04-18 00:17:4118
[email protected]86c6a0b52011-08-02 19:49:2519std::string HttpServerRequestInfo::GetHeaderValue(
20 const std::string& header_name) const {
brettw8e2106d2015-08-11 19:30:2221 DCHECK_EQ(base::ToLowerASCII(header_name), header_name);
[email protected]86c6a0b52011-08-02 19:49:2522 HttpServerRequestInfo::HeadersMap::const_iterator it =
23 headers.find(header_name);
24 if (it != headers.end())
25 return it->second;
[email protected]007b3f82013-04-09 08:46:4526 return std::string();
[email protected]86c6a0b52011-08-02 19:49:2527}
28
[email protected]bbae90f2014-05-10 19:20:3429bool HttpServerRequestInfo::HasHeaderValue(
30 const std::string& header_name,
31 const std::string& header_value) const {
brettw8e2106d2015-08-11 19:30:2232 DCHECK_EQ(base::ToLowerASCII(header_value), header_value);
33 std::string complete_value = base::ToLowerASCII(GetHeaderValue(header_name));
brettw8cc24ae22015-07-06 23:53:0034
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]bbae90f2014-05-10 19:20:3439 return true;
40 }
41 return false;
42}
43
[email protected]b6dbb0a2011-04-18 00:17:4144} // namespace net