Menu

[r9]: / framework / trunk / worker_thread.cpp  Maximize  Restore  History

Download this file

65 lines (52 with data), 1.0 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
#include "worker_thread.h"
using namespace cgicc;
Worker_Thread::Worker_Thread()
{
}
void Worker_Thread::main()
{
out.puts("<h1>Hello World</h2>\n");
}
void Worker_Thread::run(FCGX_Request *fcgi)
{
#ifdef FCGX_API_ACCEPT_ONLY_EXISTS
if(FCGX_Continue_r(fcgi)<0){
return;
}
#endif
io = auto_ptr<FCgiIO>(new FCgiIO(*fcgi));
cgi = auto_ptr<Cgicc>( new Cgicc(&*io) );
env=&(cgi->getEnvironment());
set_header(new HTTPHTMLHeader);
try {
/**********/
main();
/**********/
if(response_header.get() == NULL) {
throw HTTP_Error("Looks like a bug");
}
}
catch( HTTP_Error &error_message) {
int err_code;
out.reset();
string msg;
if(error_message.is_404()) {
err_code=404;
msg="Not Found: ";
msg+=error_message.get();
}
else {
err_code=500;
msg=error_message.get();
}
set_header(new HTTPStatusHeader(err_code,msg));
out.puts(msg.c_str());
}
*io<<*response_header;
*io<<out.get();
out.reset();
response_header.reset();
cgi.reset();
io.reset();
FCGX_Finish_r(fcgi);
}
MongoDB Logo MongoDB