From ef1654fa1ea0c0c5fda5cea1661232a30922bde9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20St=C3=B6r?= Date: Fri, 21 Apr 2017 07:49:27 +0200 Subject: [PATCH] Add 'connection: close' note --- docs/en/modules/net.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/en/modules/net.md b/docs/en/modules/net.md index 69a9ac09..6184b210 100644 --- a/docs/en/modules/net.md +++ b/docs/en/modules/net.md @@ -318,9 +318,12 @@ Otherwise, all connection errors (with normal close) passed to disconnection eve ```lua srv = net.createConnection(net.TCP, 0) srv:on("receive", function(sck, c) print(c) end) +-- Wait for connection before sending. srv:on("connection", function(sck, c) - -- Wait for connection before sending. - sck:send("GET /get HTTP/1.1\r\nHost: httpbin.org\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n") + -- 'Connection: close' rather than 'Connection: keep-alive' to have server + -- 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) srv:connect(80,"httpbin.org") ```