File: http_bundle.cpp

package info (click to toggle)
entropybroker 2.9-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,600 kB
  • sloc: cpp: 14,386; sh: 934; makefile: 188; java: 148; perl: 12
file content (58 lines) | stat: -rw-r--r-- 1,056 bytes parent folder | download | duplicates (3)
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;
}