forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp_request.h
More file actions
123 lines (97 loc) · 2.55 KB
/
http_request.h
File metadata and controls
123 lines (97 loc) · 2.55 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef Http_Request_H_
#define Http_Request_H_
class Http_Request;
extern std::set< Http_Request * > Global_WebRequests_pendingNotify;
class Http_Request : public HttpConnection
{
public:
Http_Request(SOCKET sck,Socket_Address &inaddr) : HttpConnection(sck,inaddr)
{
};
~Http_Request()
{
Global_WebRequests_pendingNotify.erase(this);
};
bool BuildPage( BufferedWriter_Growable &_writer, ParsedHttpRequest &parser)
{
Global_WebRequests_pendingNotify.insert((Http_Request *)this);
_state = WAITING_TO_FINALIZE;
_Timer.ResetAll(Time_Clock::GetCurrentTime(),Time_Span(9999999,0));
return true;
};
CloseState TryAndFinalize()
{
return ConnectionDoNotClose;
};
PUBLISHED:
std::string GetRequestType()
{
return _parser.GetRequestType();
}
std::string GetRawRequest()
{
return _parser.GetRawRequest();
}
std::string GetRequestURL()
{
return _parser.GetRequestURL();
}
std::string GetSourceAddress()
{
return _MyAddress.get_ip_port();
}
void AppendToResponse(const std::string &in)
{
_writer+=in;
}
void SendThisResponse(const std::string &in)
{
_writer+=in;
Finish();
}
void Finish()
{
_Timer.ResetAll(Time_Clock::GetCurrentTime(),Time_Span(10,0));
_state = WRITING_DATA;
};
void Abort()
{
_state = ABORTING;
};
bool HasOption(std::string in)
{
const std::string * answer = _parser.GetOption(in);
if(answer != NULL)
return true;
return false;
}
const char * GetOption(std::string in)
{
const std::string * answer = _parser.GetOption(in);
if(answer != NULL)
return answer->c_str();
return "";
}
std::string GetRequestOptionString()
{
return _parser.GetRequestOptionString();
}
static bool HttpManager_Initialize( unsigned short port);
static Http_Request * HttpManager_GetARequest();
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
HttpConnection::init_type();
register_type(_type_handle, "Http_Request",
HttpConnection::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
#endif // Http_Request_H_