Using connection:keep-alive and connection:close headers in response

This commit is contained in:
Zaid Abdulla committed 2013-03-20 22:47:32 +03:00
1 parent 6b76e5b0b2
commit de2edd0438
1 file changed
+6
+6
View File
@@ -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) ->