summaryrefslogtreecommitdiff
path: root/http_connection.h
diff options
context:
space:
mode:
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;