@@ -27,15 +27,12 @@ simple response to any HTTP request.
2727 typedef http::server<hello_world> server;
2828
2929 struct hello_world {
30- void operator()(server::request const &request, server::response &response ) {
30+ void operator()(server::request const &request, server::connection_ptr connection ) {
3131 server::string_type ip = source(request);
3232 unsigned int port = request.source_port;
3333 std::ostringstream data;
3434 data << "Hello, " << ip << ':' << port << '!';
35- response = server::response: :stock_reply(server::response: :ok, data.str());
36- }
37- void log(const server::string_type& message) {
38- std::cerr << "ERROR: " << message << std::endl;
35+ connection->write(data.str());
3936 }
4037 };
4138
@@ -103,22 +100,21 @@ This header contains all the code needed to develop an HTTP server with
103100 typedef http::server<hello_world> server;
104101
105102 struct hello_world {
106- void operator()(server::request const &request, server::response &response ) {
103+ void operator()(server::request const &request, server::connection_ptr connection ) {
107104 server::string_type ip = source(request);
108105 unsigned int port = request.source_port;
109106 std::ostringstream data;
110107 data << "Hello, " << ip << ':' << port << '!';
111- response = server::response: :stock_reply(server::response: :ok, data.str());
112- }
113- void log(const server::string_type& message) {
114- std::cerr << "ERROR: " << message << std::endl;
108+ connection->write(data.str());
115109 }
116110 };
117111
118112``hello_world `` is a functor class which handles HTTP requests.
119113All the operator does here is return an HTTP response with HTTP code 200
120114and the body ``"Hello, <ip>:<port>!" ``. The ``<ip> `` in this case would be
121115the IP address of the client that made the request and ``<port> `` the clients port.
116+ If you like to send an other status have a look at the function
117+ ``set_status(status_t status) `` from connection.
122118
123119There are a number of pre-defined stock replies differentiated by
124120status code with configurable bodies.