summaryrefslogtreecommitdiff
path: root/http_connection.h
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-01-02 22:28:26 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-01-02 22:28:26 +0100
commit0e3c3380d519b033500b4ed1ccd3acf707c34372 (patch)
tree115cbbf0200fc34011e68b32e56d58458a72d87f /http_connection.h
parent237c3e226b7c2ac391b0e8d354e5fc6f587a41ba (diff)
Merge HTTPResponse into HTTP::Connection.
Diffstat (limited to 'http_connection.h')
-rw-r--r--http_connection.h29
1 files changed, 25 insertions, 4 deletions
diff --git a/http_connection.h b/http_connection.h
index 5a01273..446f0af 100644
--- a/http_connection.h
+++ b/http_connection.h
@@ -2,6 +2,7 @@
#define HTTP_CONNECTION_H
#include <string>
+#include <vector>
#include <list>
#include <map>
@@ -20,9 +21,6 @@ namespace HTTP {
typedef boost::function<void (Connection::p)> Handler;
typedef std::list<std::string> PathList;
- //! Start reading the request headers.
- void read_request(Handler callback);
-
//! Request method.
std::string method;
@@ -47,16 +45,39 @@ namespace HTTP {
//! Send error.
void send_error(int code, std::string name);
- tcp::socket socket;
+ //! Add response header.
+ void add_header(std::string key, std::string value);
+
+ //! Send data.
+ void send_data(const std::string& data);
+ void send_data(const void* data, std::size_t size);
+
private:
+ typedef std::vector<std::pair<std::string, std::string> > HeaderList;
+
+ //! Constructor.
Connection(boost::asio::io_service& io_service);
+
+ //! Start reading the request headers.
+ void read_request(Handler callback);
+
void handle_write(const boost::system::error_code& error, size_t bytes_transferred);
void handle_read(const boost::system::error_code& error, size_t bytes_transferred, Handler callback);
+ tcp::socket socket;
boost::asio::streambuf buf;
+ //! Response headers.
+ HeaderList response_headers;
+
//! Parse request headers.
bool parse_request(boost::asio::streambuf& buf);
+
+ //! Write response headers.
+ void write_headers();
+
+ //! Response headers written?
+ bool headers_written;
};
typedef Connection::Handler Handler;