NetFlex  0.0.0
C++11 HTTP Server Library.
response.hpp
1 // The MIT License (MIT)
2 //
3 // Copyright (c) 2015-2017 Simon Ninon <simon.ninon@gmail.com>
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #pragma once
24 
25 #include <string>
26 
27 #include <netflex/http/header.hpp>
28 
29 namespace netflex {
30 
31 namespace http {
32 
37 class response {
38 public:
40  response(void);
42  ~response(void) = default;
43 
45  response(const response&) = default;
47  response& operator=(const response&) = default;
48 
49 public:
53  const std::string& get_http_version(void) const;
54 
58  unsigned int get_status_code(void) const;
59 
63  const std::string& get_reason_phase(void) const;
64 
70  void set_http_version(const std::string& version);
71 
77  void set_status_code(unsigned int code);
78 
84  void set_reason_phrase(const std::string& reason);
85 
86 public:
90  const header_list_t& get_headers(void) const;
91 
98  void add_header(const header& header);
99 
105  void set_headers(const header_list_t& headers);
106 
107 public:
111  const std::string& get_body(void) const;
112 
118  void set_body(const std::string& body);
119 
120 public:
126  std::string to_http_packet(void) const;
127 
128 private:
132  std::string m_http_version;
133 
137  unsigned int m_status;
138 
142  std::string m_reason;
143 
147  header_list_t m_headers;
148 
152  std::string m_body;
153 };
154 
155 } // namespace http
156 
157 } // namespace netflex
Definition: header.hpp:36
void set_http_version(const std::string &version)
response(void)
default ctor
const header_list_t & get_headers(void) const
void set_headers(const header_list_t &headers)
void add_header(const header &header)
void set_body(const std::string &body)
unsigned int get_status_code(void) const
void set_reason_phrase(const std::string &reason)
void set_status_code(unsigned int code)
Definition: client.hpp:33
const std::string & get_body(void) const
const std::string & get_http_version(void) const
Definition: response.hpp:37
const std::string & get_reason_phase(void) const
~response(void)=default
default dtor
response & operator=(const response &)=default
assignment operator
std::string to_http_packet(void) const