Fix keep alive header
This commit is contained in:
1 parent
2f5ac709ba
commit
68a32afc38
3 files changed
+16
-12
No files matched your search
@@ -69,7 +69,6 @@ namespace Http
|
|||||||
m.SetBodyDataString(buffer)
|
m.SetBodyDataString(buffer)
|
||||||
m.ContentType("text/html")
|
m.ContentType("text/html")
|
||||||
|
|
||||||
m.GenerateHeader(true)
|
|
||||||
m.source = Http.HttpResponseSource.GENERATED
|
m.source = Http.HttpResponseSource.GENERATED
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -86,7 +85,6 @@ namespace Http
|
|||||||
m.SetBodyDataString(buffer)
|
m.SetBodyDataString(buffer)
|
||||||
m.ContentType("application/json")
|
m.ContentType("application/json")
|
||||||
|
|
||||||
m.GenerateHeader(true)
|
|
||||||
m.source = Http.HttpResponseSource.GENERATED
|
m.source = Http.HttpResponseSource.GENERATED
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -131,6 +129,10 @@ namespace Http
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function SendHeader(sock as object, bufsize as integer) as integer
|
function SendHeader(sock as object, bufsize as integer) as integer
|
||||||
|
if m.header = invalid
|
||||||
|
m.GenerateHeader()
|
||||||
|
end if
|
||||||
|
|
||||||
if m.header_sent = 0
|
if m.header_sent = 0
|
||||||
sent = sock.sendStr(m.header)
|
sent = sock.sendStr(m.header)
|
||||||
else
|
else
|
||||||
@@ -143,13 +145,16 @@ namespace Http
|
|||||||
return sent
|
return sent
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GenerateHeader(close = false as boolean)
|
function GenerateHeader()
|
||||||
code = m.http_code
|
code = m.http_code
|
||||||
title = WebUtils.HttpTitle(code)
|
title = WebUtils.HttpTitle(code)
|
||||||
|
|
||||||
m.headers["Date"] = m.Now()
|
m.headers["Date"] = m.Now()
|
||||||
m.headers["Server"] = m.settings.PackageName
|
m.headers["Server"] = m.settings.PackageName
|
||||||
m.KeepAlive(close)
|
|
||||||
|
if not m.headers.DoesExist("Connection")
|
||||||
|
m.KeepAlive(false)
|
||||||
|
end if
|
||||||
|
|
||||||
m.header = "HTTP/1.1" + Stri(code) + " " + title + WinNL()
|
m.header = "HTTP/1.1" + Stri(code) + " " + title + WinNL()
|
||||||
for each header in m.headers
|
for each header in m.headers
|
||||||
@@ -172,13 +177,13 @@ namespace Http
|
|||||||
m.log.info("Sent" + Stri(recent) + " [" + m.MakeRange(from, recent, total) + "]")
|
m.log.info("Sent" + Stri(recent) + " [" + m.MakeRange(from, recent, total) + "]")
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function KeepAlive(close as boolean)
|
function KeepAlive(keepAlive as boolean)
|
||||||
if close
|
if keepAlive
|
||||||
|
m.headers["Connection"] = "keep-alive"
|
||||||
|
m.headers["Keep-Alive"] = "timeout=" + Stri(m.settings.Idletime).trim()
|
||||||
|
else
|
||||||
m.headers["Connection"] = "close"
|
m.headers["Connection"] = "close"
|
||||||
m.headers.Delete("Keep-Alive")
|
m.headers.Delete("Keep-Alive")
|
||||||
else
|
|
||||||
m.headers["Keep-Alive"] = "timeout=" + Stri(m.settings.Idletime).trim()
|
|
||||||
m.headers.Delete("Connection")
|
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ namespace Http
|
|||||||
response.http_code = resp.statuscode
|
response.http_code = resp.statuscode
|
||||||
response.SetBodyDataString(text)
|
response.SetBodyDataString(text)
|
||||||
response.ContentType("application/dash+xml")
|
response.ContentType("application/dash+xml")
|
||||||
response.GenerateHeader(true)
|
|
||||||
response.source = Http.HttpResponseSource.GENERATED
|
response.source = Http.HttpResponseSource.GENERATED
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ namespace Http
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
response.headers["Accept-Ranges"] = "bytes"
|
response.headers["Accept-Ranges"] = "bytes"
|
||||||
response.GenerateHeader()
|
response.KeepAlive(true)
|
||||||
return true
|
return true
|
||||||
end function
|
end function
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ namespace Http
|
|||||||
|
|
||||||
response.SetBodyDataString(listing)
|
response.SetBodyDataString(listing)
|
||||||
response.http_code = 200
|
response.http_code = 200
|
||||||
response.GenerateHeader()
|
response.KeepAlive(true)
|
||||||
response.source = Http.HttpResponseSource.GENERATED
|
response.source = Http.HttpResponseSource.GENERATED
|
||||||
return true
|
return true
|
||||||
end function
|
end function
|
||||||
|
|||||||
Reference in new issue
Block a user