forked from dreiss/old-thrift
/
THttpServer.h
57 lines (42 loc) · 1.31 KB
/
THttpServer.h
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
// Copyright (c) 2006- Facebook
// Distributed under the Thrift Software License
//
// See accompanying file LICENSE or visit the Thrift site at:
// http://developers.facebook.com/thrift/
#ifndef _THRIFT_TRANSPORT_THTTPSERVER_H_
#define _THRIFT_TRANSPORT_THTTPSERVER_H_ 1
#include <transport/THttpTransport.h>
namespace facebook { namespace thrift { namespace transport {
/**
* HTTP server transport implementation.
*
* @author Jeremie BORDIER <jeremie.bordier@gmail.com>
*/
class THttpServer : public THttpTransport {
public:
THttpServer(boost::shared_ptr<TTransport> transport);
virtual ~THttpServer();
virtual void flush();
protected:
void readHeaders();
virtual void parseHeader(char* header);
virtual bool parseStatusLine(char* status);
};
/**
* Wraps a transport into HTTP protocol
*
* @author Jeremie BORDIER <jeremie.bordier@gmail.com>
*/
class THttpServerTransportFactory : public TTransportFactory {
public:
THttpServerTransportFactory() {}
virtual ~THttpServerTransportFactory() {}
/**
* Wraps the transport into a buffered one.
*/
virtual boost::shared_ptr<TTransport> getTransport(boost::shared_ptr<TTransport> trans) {
return boost::shared_ptr<TTransport>(new THttpServer(trans));
}
};
}}} // facebook::thrift::transport
#endif // #ifndef _THRIFT_TRANSPORT_THTTPSERVER_H_