moonbridge

changeset 32:fd542c33020b

Method request:send_text_status_response(...) doesn't enfoce connection close
author jbe
date Tue Feb 17 04:10:38 2015 +0100 (2015-02-17)
parents 5ab8c0260e59
children 59f485dc48ea
files moonbridge_http.lua
line diff
     1.1 --- a/moonbridge_http.lua	Tue Feb 17 00:50:53 2015 +0100
     1.2 +++ b/moonbridge_http.lua	Tue Feb 17 04:10:38 2015 +0100
     1.3 @@ -759,9 +759,6 @@
     1.4          send_text_status_response = function(self, status, text)
     1.5            request:send_status(status)
     1.6            request:send_header("Content-Type", "text/plain")
     1.7 -          if not connection_close_responded then
     1.8 -            request:send_header("Connection", "close")
     1.9 -          end
    1.10            request:send_data(status, "\n")
    1.11            if text then
    1.12              request:send_data("\n", text, "\n")
    1.13 @@ -790,11 +787,18 @@
    1.14            end
    1.15          end
    1.16        })
    1.17 -      -- wrapper for request:send_text_status_response(...) method to
    1.18 -      -- send an error status for malformed requests, etc., and to
    1.19 -      -- return the boolean value of the "survive" variable:
    1.20 +      -- function identical to request:send_text_status_response(...)
    1.21 +      -- but enforcing a connection close after sending the response, and
    1.22 +      -- returning the boolean value of the "survive" variable:
    1.23        local function error_response(...)
    1.24 -        request:send_text_status_response(...)
    1.25 +        request:send_status(status)
    1.26 +        request:send_header("Content-Type", "text/plain")
    1.27 +        request:send_header("Connection", "close")
    1.28 +        request:send_data(status, "\n")
    1.29 +        if text then
    1.30 +          request:send_data("\n", text, "\n")
    1.31 +        end
    1.32 +        request:finish()
    1.33          return survive
    1.34        end
    1.35        -- read and parse request line:

Impressum / About Us