Skip to content

Commit

Permalink
http-hello close connection when http/1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yedf committed Apr 26, 2016
1 parent f7a94aa commit a2a2ea2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/http-hello.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ int main(int argc, const char* argv[]) {
int r = sample.bind("", 8081);
exitif(r, "bind failed %d %s", errno, strerror(errno));
sample.onGet("/hello", [](const HttpConnPtr& con) {
string v = con.getRequest().version;
HttpResponse resp;
resp.body = Slice("hello world");
con.sendResponse(resp);
if (v == "HTTP/1.0") {
con->close();
}
});
Signal::signal(SIGINT, [&]{base.exit();});
base.loop();
Expand Down

0 comments on commit a2a2ea2

Please sign in to comment.