Menu

[r754]: / framework / branches / refactoring / cgi_api.h  Maximize  Restore  History

Download this file

94 lines (67 with data), 2.4 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
#ifndef CPPCMS_IMPL_CGI_API_H
#define CPPCMS_IMPL_CGI_API_H
#include "noncopyable.h"
#include <vector>
#include <boost/enable_shared_from_this.hpp>
#include <boost/function.hpp>
#include <boost/system/error_code.hpp>
namespace boost { namespace asio { class io_service; } }
namespace cppcms {
class service;
class application;
namespace http {
class context;
}
namespace impl {
namespace cgi {
typedef boost::function<void(boost::system::error_code const &e)> handler;
typedef boost::function<void(boost::system::error_code const &e,size_t)> io_handler;
class acceptor : public util::noncopyable {
public:
virtual void async_accept() = 0;
virtual void stop() = 0;
virtual ~acceptor(){}
};
class connection :
public boost::enable_shared_from_this<connection>,
public util::noncopyable
{
public:
void on_accepted();
connection(cppcms::service &srv);
virtual ~connection();
cppcms::service &service();
/****************************************************************************/
// These are abstract member function that should be implemented by
// actual protocol like FCGI, SCGI, HTTP or CGI
virtual void async_read_headers(handler const &h) = 0;
virtual std::string getenv(std::string const &key) = 0;
virtual bool keep_alive() = 0;
// Concept implementation headers
virtual void async_read_some(void *,size_t,io_handler const &h) = 0;
virtual void async_write_some(void const *,size_t,io_handler const &h) = 0;
virtual size_t write_some(void const *,size_t) = 0;
virtual boost::asio::io_service &get_io_service() = 0;
/****************************************************************************/
protected:
void async_read(void *,size_t,io_handler const &h);
void async_write(void const *,size_t,io_handler const &h);
private:
void load_content(boost::system::error_code const &e);
void process_request(boost::system::error_code const &e);
void load_multipart_form_data();
void make_error_response(int statis,char const *msg="");
void setup_application();
void dispatch(bool thread);
void on_response_complete();
void try_restart(boost::system::error_code const &);
std::auto_ptr<http::context> context_;
std::vector<char> content_;
std::auto_ptr<application> application_;
cppcms::service *service_;
std::string async_chunk_;
};
} // cgi
} // impl
} // cppcms
#endif
MongoDB Logo MongoDB