libzypp  17.38.17
httpheader.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 ----------------------------------------------------------------------/
9 */
10 #ifndef ZYPP_CURL_NG_NETWORK_HTTPHEADER_H_INCLUDED
11 #define ZYPP_CURL_NG_NETWORK_HTTPHEADER_H_INCLUDED
12 
13 #include <string>
14 #include <zypp-core/base/String.h>
15 
16 namespace zyppng
17 {
21  class HttpHeader
22  {
23  public:
24  HttpHeader( std::string key_r, std::string value_r )
25  : _key { zypp::str::trim( key_r ) }
26  , _value { zypp::str::trim( value_r ) }
27  {}
28 
29  const std::string & key() const { return _key; }
30  const std::string & value() const { return _value; }
31 
39  std::string asString() const
40  { return _key + ": " + _value; }
41 
42  static std::string asString( std::string key_r, std::string value_r )
43  { return HttpHeader( key_r, value_r ).asString(); }
44 
45  private:
46  std::string _key;
47  std::string _value;
48  };
49 } // namespace zyppng
50 #endif // ZYPP_CURL_NG_NETWORK_HTTPHEADER_H_INCLUDED
std::string asString() const
Return valid HTTP header string.
Definition: httpheader.h:39
HttpHeader(std::string key_r, std::string value_r)
Definition: httpheader.h:24
const std::string & value() const
Definition: httpheader.h:30
const std::string & key() const
Definition: httpheader.h:29
std::string trim(const std::string &s, const Trim trim_r)
Definition: String.cc:226
static std::string asString(std::string key_r, std::string value_r)
Definition: httpheader.h:42
Store and provide HTTP header data (key/value).
Definition: httpheader.h:21
std::string _key
Definition: httpheader.h:46
std::string _value
Definition: httpheader.h:47