SpiecsEngine
 
Loading...
Searching...
No Matches
HttpRequest.cpp
Go to the documentation of this file.
1/**
2* @file HttpRequest.cpp.
3* @brief The HttpRequest Class Implementation.
4* @author Spices & Muduo.
5*/
6
7#include "Pchheader.h"
8#include "HttpRequest.h"
9
10namespace Spices {
11
12namespace Net {
13
14 void HttpRequest::SetPath(const std::string& path)
15 {
17
18 m_Path = path;
19 }
20
22 {
24
25 m_Method = method;
26 }
27
29 {
31
32 m_Version = version;
33 }
34
35 void HttpRequest::AddParameter(const std::string& name, const std::string& value)
36 {
38
39 m_Parameters[name] = value;
40 }
41
42 void HttpRequest::AddHeader(const std::string& name, const std::string& value)
43 {
45
46 m_Headers[name] = value;
47 }
48
49 std::string HttpRequest::GetHeader(const std::string& name) const
50 {
52
53 if (m_Headers.find(name) == m_Headers.end())
54 {
55 std::stringstream ss;
56 ss << name << " is not found in Http Header";
57
58 SPICES_CORE_WARN(ss.str())
59 return "";
60 }
61
62 return m_Headers.find(name)->second;
63 }
64
66 {
68
69 std::swap(m_Method, rhs.m_Method);
70 std::swap(m_Version, rhs.m_Version);
71 m_Path.swap(rhs.m_Path);
72 m_Parameters.swap(rhs.m_Parameters);
73 m_Headers.swap(rhs.m_Headers);
74 }
75
76}
77
78}
#define SPICES_PROFILE_ZONE
Version m_Version
Http Version.
void Swap(HttpRequest &rhs)
Swap with another HttpRequest.
void AddHeader(const std::string &name, const std::string &value)
Add a Header to this HttpRequest.
void SetMethod(Method method)
Set Http Method.
void AddParameter(const std::string &name, const std::string &value)
Add a Parameter to this HttpRequest.
std::string m_Path
Http Path.
Method m_Method
Http Method.
std::string GetHeader(const std::string &name) const
Get a Header from this HttpRequest.
void SetVersion(Version version)
Set Http Version.
void SetPath(const std::string &path)
Set Http path.
Http Request body.
Definition HttpRequest.h:18