Commit ef1654fa authored by Marcel Stör's avatar Marcel Stör
Browse files

Add 'connection: close' note

parent 9d11543f
...@@ -318,9 +318,12 @@ Otherwise, all connection errors (with normal close) passed to disconnection eve ...@@ -318,9 +318,12 @@ Otherwise, all connection errors (with normal close) passed to disconnection eve
```lua ```lua
srv = net.createConnection(net.TCP, 0) srv = net.createConnection(net.TCP, 0)
srv:on("receive", function(sck, c) print(c) end) srv:on("receive", function(sck, c) print(c) end)
-- Wait for connection before sending.
srv:on("connection", function(sck, c) srv:on("connection", function(sck, c)
-- Wait for connection before sending. -- 'Connection: close' rather than 'Connection: keep-alive' to have server
sck:send("GET /get HTTP/1.1\r\nHost: httpbin.org\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n") -- initiate a close of the connection after final response (frees memory
-- earlier here), http://bit.ly/2pkOrsi
sck:send("GET /get HTTP/1.1\r\nHost: httpbin.org\r\nConnection: close\r\nAccept: */*\r\n\r\n")
end) end)
srv:connect(80,"httpbin.org") srv:connect(80,"httpbin.org")
``` ```
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment