-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynamic_resource.cpp
More file actions
52 lines (37 loc) · 1.52 KB
/
dynamic_resource.cpp
File metadata and controls
52 lines (37 loc) · 1.52 KB
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
//-----------------------------------------------------------------------------
/*!
\file
\brief Non blocking TCP connection class
*/
//-----------------------------------------------------------------------------
/* -- Includes ------------------------------------------------------------ */
#include <string>
#include "dynamic_resource.h"
/* -- Defines ------------------------------------------------------------- */
using namespace std;
/* -- Types --------------------------------------------------------------- */
/* -- (Module) Global Variables ------------------------------------------- */
/* -- Module Global Function Prototypes ----------------------------------- */
extern "C" unsigned int xcrc32 (const unsigned char *buf, int len, unsigned int init);
/* -- Implementation ------------------------------------------------------ */
DynamicResource::DynamicResource(const string& uri, const string& statusCode)
{
this->uri = uri;
this->content = "";
this->contentType = "text/plain";
this->statusCode = statusCode;
this->hash = 1; //this prevents an immediate load empty resources
}
void DynamicResource::setContentType(const std::string& contentType)
{
this->contentType = contentType;
}
void DynamicResource::setContent(const std::string& content)
{
this->content = content;
this->hash = xcrc32((const unsigned char *)content.c_str(), content.length(), 0xFFFFFFFFuL);
if (this->hash == 0)
{
this->hash = 1; //value of 0 is reserved, thats why it shall never be a regular hash
}
}