Using connection:keep-alive and connection:close headers in response
This commit is contained in:
1 parent
6b76e5b0b2
commit
de2edd0438
1 file changed
+6
@@ -28,6 +28,12 @@ applyConfigurations = (currentRequest, taskList) ->
|
|||||||
|
|
||||||
|
|
||||||
writeResponse = (currentRequest, res) ->
|
writeResponse = (currentRequest, res) ->
|
||||||
|
if res.headers['Content-Length'] == 0
|
||||||
|
# no more requests. terminate TCP connection
|
||||||
|
res.headers['Connection'] = 'close' if currentRequest.httpRequest.httpVersion == '1.1'
|
||||||
|
else
|
||||||
|
res.headers['Connection'] = 'Keep-Alive' if currentRequest.httpRequest.httpVersion == '1.0'
|
||||||
|
|
||||||
if config.DEBUG_DEVICES[currentRequest.deviceId]
|
if config.DEBUG_DEVICES[currentRequest.deviceId]
|
||||||
dump = "# RESPONSE #{new Date(Date.now())}\n" + JSON.stringify(res.headers) + "\n#{res.data}\n\n"
|
dump = "# RESPONSE #{new Date(Date.now())}\n" + JSON.stringify(res.headers) + "\n#{res.data}\n\n"
|
||||||
fs = require('fs').appendFile("debug/#{currentRequest.deviceId}.dump", dump, (err) ->
|
fs = require('fs').appendFile("debug/#{currentRequest.deviceId}.dump", dump, (err) ->
|
||||||
|
|||||||
Reference in new issue
Block a user