summaryrefslogtreecommitdiff
path: root/src/HttpServer.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-07-14 18:59:56 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-07-14 18:59:56 +0900
commit7100b1b9ca10f8bd940ff436b2a16f91d34d5429 (patch)
treeb7a31fb6e5a0cf01ad110bdb11dde0dffa7da697 /src/HttpServer.h
parent5352d76d4f24a8ad7096979f8f826a1dd0d8e5d7 (diff)
Parse HTTP RPC request on the fly without buffering
Diffstat (limited to 'src/HttpServer.h')
-rw-r--r--src/HttpServer.h33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/HttpServer.h b/src/HttpServer.h
index d16916a8..995102a0 100644
--- a/src/HttpServer.h
+++ b/src/HttpServer.h
@@ -51,7 +51,17 @@ class HttpHeader;
class HttpHeaderProcessor;
class DownloadEngine;
class SocketRecvBuffer;
+class DiskWriter;
+enum RequestType {
+ RPC_TYPE_NONE,
+ RPC_TYPE_XML,
+ RPC_TYPE_JSON,
+ RPC_TYPE_JSONP
+};
+
+// HTTP server class handling RPC request from the client. It is not
+// intended to be a generic HTTP server.
class HttpServer {
private:
SharedHandle<SocketCore> socket_;
@@ -61,7 +71,11 @@ private:
SharedHandle<HttpHeaderProcessor> headerProcessor_;
SharedHandle<HttpHeader> lastRequestHeader_;
int64_t lastContentLength_;
- std::stringstream lastBody_;
+ // How many bytes are consumed. The total number of bytes is
+ // lastContentLength_.
+ int64_t bodyConsumed_;
+ RequestType reqType_;
+ SharedHandle<DiskWriter> lastBody_;
bool keepAlive_;
bool gzip_;
std::string username_;
@@ -78,12 +92,25 @@ public:
bool receiveBody();
- std::string getBody() const;
-
const std::string& getMethod() const;
const std::string& getRequestPath() const;
+ int setupResponseRecv();
+
+ std::string createPath() const;
+
+ std::string createQuery() const;
+
+ const SharedHandle<DiskWriter>& getBody() const
+ {
+ return lastBody_;
+ }
+
+ RequestType getRequestType() const
+ {
+ return reqType_;
+ }
void feedResponse(std::string& text, const std::string& contentType);