forked from idkwim/entropybroker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
http_bundle.cpp
58 lines (45 loc) · 1.03 KB
/
http_bundle.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>
#include "http_bundle.h"
http_bundle::http_bundle(std::vector<std::string> headers_in, unsigned char *data_in, int data_len_in)
{
headers = headers_in;
data = NULL;
data_len = 0;
if (data_in)
{
data = reinterpret_cast<unsigned char *>(malloc(data_len_in));
memcpy(data, data_in, data_len_in);
data_len = data_len_in;
}
}
http_bundle::http_bundle(std::vector<std::string> headers_in, const char *data_in)
{
headers = headers_in;
data = reinterpret_cast<unsigned char *>(strdup(data_in));
data_len = strlen(data_in);
}
http_bundle::http_bundle(std::vector<std::string> headers_in, std::string data_in)
{
headers = headers_in;
data = reinterpret_cast<unsigned char *>(strdup(data_in.c_str()));
data_len = data_in.size();
}
http_bundle::~http_bundle()
{
free(data);
}
std::vector<std::string> http_bundle::get_headers()
{
return headers;
}
int http_bundle::get_data_len()
{
return data_len;
}
unsigned char *http_bundle::get_data()
{
return data;
}