File tree 2 files changed +12
-7
lines changed
boost/network/protocol/http
2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -45,11 +45,6 @@ namespace boost { namespace network { namespace http {
45
45
, socket_(service_)
46
46
, wrapper_(service_)
47
47
{
48
- try {
49
- socket_.set_option (tcp::no_delay (true )); // Don't delay writing
50
- } catch (system ::system_error & e) {
51
- handler_.log (e.what ());
52
- }
53
48
}
54
49
55
50
tcp::socket & socket () {
@@ -62,6 +57,9 @@ namespace boost { namespace network { namespace http {
62
57
// and then pass that request object to the
63
58
// handler_ instance.
64
59
//
60
+ boost::system ::error_code option_error;
61
+ socket_.set_option (tcp::no_delay (true ), option_error);
62
+ if (option_error) handler_.log (system ::system_error (option_error).what ());
65
63
socket_.async_read_some (
66
64
boost::asio::buffer (buffer_),
67
65
wrapper_.wrap (
Original file line number Diff line number Diff line change @@ -16,20 +16,26 @@ namespace http = boost::network::http;
16
16
using boost::assign::list_of;
17
17
using boost::lexical_cast;
18
18
using std::string;
19
+ using std::cerr;
20
+ using std::endl;
19
21
20
22
struct hello_world ;
21
23
typedef http::server<hello_world> server;
22
24
23
25
struct hello_world {
26
+
24
27
void operator ()(server::request const & request, server::response & response) {
25
28
response = server::response::stock_reply (server::response::ok, " Hello, World!" );
26
29
assert (response.status == server::response::ok);
27
30
assert (response.headers .size () == 2 );
28
31
assert (response.content == " Hello, World!" );
29
32
}
30
- void log (...) {
31
- // do nothing
33
+
34
+ void log (string const & data) {
35
+ cerr << data << endl;
36
+ abort ();
32
37
}
38
+
33
39
};
34
40
35
41
int main (int argc, char * argv[]) {
@@ -38,3 +44,4 @@ int main(int argc, char * argv[]) {
38
44
server_.run ();
39
45
return EXIT_SUCCESS;
40
46
}
47
+
You can’t perform that action at this time.
0 commit comments