proxygen
Header.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #pragma once
11 
13 #include <string>
14 
15 namespace proxygen { namespace compress {
16 
21 struct Header {
23  const std::string* name;
25 
27  const std::string& v)
28  : code(c), name(HTTPCommonHeaders::getPointerToHeaderName(c)), value(&v) {}
29 
31  const std::string& n,
32  const std::string& v)
33  : code(c), name(&n), value(&v) {}
34 
35  bool operator<(const Header& h) const {
36  return (code < h.code) ||
37  ((code == h.code) && (*name < *h.name));
38  }
39 
40  // For use by tests
41  static Header makeHeaderForTest(const std::string& n, const std::string& v) {
42  return Header(n, v);
43  }
44 
45  private:
46  // This constructor ideally should not be used in production code
47  // This is because in prod the common header code is likely already known and
48  // an above constructor could be used; this exists for test purposes
49  Header(const std::string& n, const std::string& v)
50  : code(HTTPCommonHeaders::hash(n)), name(&n), value(&v) {}
51 };
52 
53 }}
const std::string * value
Definition: Header.h:24
*than *hazptr_holder h
Definition: Hazptr.h:116
const std::string * name
Definition: Header.h:23
Header(const std::string &n, const std::string &v)
Definition: Header.h:49
Header(HTTPHeaderCode c, const std::string &n, const std::string &v)
Definition: Header.h:30
HTTPHeaderCode code
Definition: Header.h:22
Header(HTTPHeaderCode c, const std::string &v)
Definition: Header.h:26
const char * string
Definition: Conv.cpp:212
char c
static Header makeHeaderForTest(const std::string &n, const std::string &v)
Definition: Header.h:41
bool operator<(const Header &h) const
Definition: Header.h:35