NetFlex  0.0.0
C++11 HTTP Server Library.
request.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 #include <netflex/http/method.hpp>
29 #include <netflex/routing/params.hpp>
30 
31 namespace netflex {
32 
33 namespace http {
34 
39 class request {
40 public:
42  request(void) = default;
44  ~request(void) = default;
45 
47  request(const request&) = default;
49  request& operator=(const request&) = default;
50 
51 public:
55  method get_method(void) const;
56 
60  const std::string& get_raw_method(void) const;
61 
65  const std::string& get_target(void) const;
66 
70  const std::string& get_http_version(void) const;
71 
77  void set_method(method method);
78 
84  void set_raw_method(const std::string& method);
85 
91  void set_target(const std::string& target);
92 
98  void set_http_version(const std::string& http_version);
99 
100 public:
108  const std::string& get_header(const std::string& name) const;
109 
113  const header_list_t& get_headers(void) const;
114 
120  void set_headers(const header_list_t& headers);
121 
128  void add_header(const header& header);
129 
136  bool has_header(const std::string& name) const;
137 
144  void remove_header(const std::string& name);
145 
146 public:
150  const std::string& get_path(void) const;
151 
155  const routing::params_t& get_params(void) const;
156 
162  void set_path(const std::string& path);
163 
169  void set_params(const routing::params_t& params);
170 
171 public:
175  const std::string& get_body(void) const;
176 
182  void set_body(const std::string& body);
183 
184 public:
188  std::string to_string(void) const;
189 
190 private:
194  method m_method;
195 
199  std::string m_raw_method;
200 
204  std::string m_target;
205 
209  std::string m_http_version;
210 
214  header_list_t m_headers;
215 
219  std::string m_path;
220 
224  routing::params_t m_params;
225 
229  std::string m_body;
230 };
231 
232 } // namespace http
233 
234 } // namespace netflex
void set_target(const std::string &target)
void set_raw_method(const std::string &method)
const std::string & get_body(void) const
Definition: header.hpp:36
method get_method(void) const
const routing::params_t & get_params(void) const
~request(void)=default
default dtor
request & operator=(const request &)=default
assignment operator
void set_method(method method)
request(void)=default
default ctor
const std::string & get_header(const std::string &name) const
void set_params(const routing::params_t &params)
void set_http_version(const std::string &http_version)
void remove_header(const std::string &name)
const header_list_t & get_headers(void) const
std::string to_string(void) const
Definition: client.hpp:33
const std::string & get_raw_method(void) const
void add_header(const header &header)
const std::string & get_target(void) const
bool has_header(const std::string &name) const
void set_body(const std::string &body)
const std::string & get_http_version(void) const
void set_headers(const header_list_t &headers)
Definition: request.hpp:39
const std::string & get_path(void) const
void set_path(const std::string &path)