SaltAPI  1.1
An API for the HTTPd / Zia by Salty Studio.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Message.cpp
Go to the documentation of this file.
1 //
2 // Created by wery_a on 09/01/17.
3 //
4 
5 #include <sstream>
6 #include <cstring>
7 #include "HTTP/Message.hpp"
8 
9 namespace HTTP {
11 
12  }
13 
15  delete m_body;
16  }
17 
19  return m_header;
20  }
21 
22  char *const Message::GetBody() const {
23  return m_body;
24  }
25 
26  std::string Message::GetHTTPVersion() const {
27  std::ostringstream oss;
28 
29  oss << "HTTP/" << m_http_version_major << "." << m_http_version_minor;
30  return oss.str();
31  }
32 
33  void Message::SetHTTPVersion(unsigned char major, unsigned char minor) {
34  m_http_version_major = major;
35  m_http_version_minor = minor;
36  }
37 
38  void Message::SetBody(std::string const &body) {
39  SetBody(body.c_str(), body.length());
40  }
41 
42  void Message::SetBody(const char *body, unsigned long size) {
43  if (m_body) {
44  delete m_body;
45  }
46  m_body = new char[size];
47  std::memcpy(m_body, body, size);
48  }
49 
50  CommunicationSession *Message::GetSocket() const {
52  }
53 }
CommunicationSession * GetSocket() const
Definition: Message.cpp:50
unsigned char m_http_version_major
Definition: Message.hpp:26
char *const GetBody() const
Definition: Message.cpp:22
std::string GetHTTPVersion() const
Definition: Message.cpp:26
virtual ~Message()
Definition: Message.cpp:14
Header & GetHeader()
Definition: Message.cpp:18
CommunicationSession * m_communicationSession
Definition: Message.hpp:35
unsigned char m_http_version_minor
Definition: Message.hpp:27
Header m_header
Definition: Message.hpp:29
char * m_body
Definition: Message.hpp:31
void SetHTTPVersion(unsigned char major, unsigned char minor)
set version of HTTP
Definition: Message.cpp:33
void SetBody(std::string const &body)
set body
Definition: Message.cpp:38