@@ -33,30 +33,15 @@ struct async_hello_world {
33
33
static server::response_header headers[] = {
34
34
{" Connection" , " close" }
35
35
, {" Content-Type" , " text/plain" }
36
- , {" Server" , " cpp-netlib/0.9-devel" }
36
+ , {" Server" , " cpp-netlib/0.9" }
37
+ , {" Content-Length" , " 13" }
37
38
};
38
- if (request.method == " HEAD" ) {
39
- connection->set_status (server::connection::ok);
40
- connection->set_headers (boost::make_iterator_range (headers, headers+3 ));
41
- } else {
42
- if (request.method == " PUT" || request.method == " POST" ) {
43
- static std::string bad_request (" Bad Request." );
44
- server::request::headers_container_type::iterator found =
45
- boost::find_if (request.headers , is_content_length ());
46
- if (found == request.headers .end ()) {
47
- connection->set_status (server::connection::bad_request);
48
- connection->set_headers (boost::make_iterator_range (headers, headers+3 ));
49
- connection->write (bad_request);
50
- return ;
51
- }
52
- }
53
- static char const * hello_world = " Hello, World!" ;
54
- connection->set_status (server::connection::ok);
55
- connection->set_headers (boost::make_iterator_range (headers, headers+3 ));
56
- std::vector<boost::asio::const_buffer> iovec ;
57
- iovec .push_back (boost::asio::const_buffer (hello_world, 13 ));
58
- connection->write (iovec , boost::bind (&async_hello_world::error, this , _1));
59
- }
39
+ static char const * hello_world = " Hello, World!" ;
40
+ connection->set_status (server::connection::ok);
41
+ connection->set_headers (boost::make_iterator_range (headers, headers+4 ));
42
+ std::vector<boost::asio::const_buffer> iovec ;
43
+ iovec .push_back (boost::asio::const_buffer (hello_world, 13 ));
44
+ connection->write (iovec , boost::bind (&async_hello_world::error, this , _1));
60
45
}
61
46
62
47
void error (boost::system::error_code const & ec) {
@@ -69,6 +54,7 @@ int main(int argc, char * argv[]) {
69
54
async_hello_world handler;
70
55
std::string port = " 8000" ;
71
56
if (argc > 1 ) port = argv[1 ];
57
+ std::cerr << " Configuration: port = " << port << std::endl;
72
58
server instance (" 127.0.0.1" , port, handler, thread_pool, http::_reuse_address=true );
73
59
instance.run ();
74
60
return 0 ;
0 commit comments