Add support for keep-alive (Doesn't work right now, idk why)
This commit is contained in:
parent
d5664f33e1
commit
1b36386eae
@ -114,6 +114,9 @@ def simpleResponse(connection,status,headers = None,content = None,autolength =
|
||||
if content != None and autolength == True:
|
||||
headers["Content-Length"] = str(len(content))
|
||||
|
||||
if allowKeepAlive and not ("Connection" in headers):
|
||||
headers["Connection"] = "keep-alive"
|
||||
headers["Keep-Alive"] = "timeout=" +str(timeout)
|
||||
response = 'HTTP/1.1 ' +status+ '\r\n'
|
||||
for header in headers:
|
||||
response += header + ": " +headers[header] + "\r\n"
|
||||
|
@ -12,6 +12,7 @@ pathHandlers = {}
|
||||
|
||||
global clientLoopIn
|
||||
def clientLoopIn(self):
|
||||
while True:
|
||||
env = {}
|
||||
env["self"] = self
|
||||
env["requestTime"] = time.time()
|
||||
@ -82,4 +83,8 @@ def clientLoopIn(self):
|
||||
env["handler"](env)
|
||||
else:
|
||||
handle404(env)
|
||||
return
|
||||
|
||||
if allowKeepAlive:
|
||||
if "connection" in env["headerList"] and env["headerList"]["connection"] == "keep-alive":
|
||||
continue
|
||||
break
|
@ -4,3 +4,5 @@ global indexPath
|
||||
indexPath = p(sp,"index")
|
||||
global readBufferSize
|
||||
readBufferSize = 32768
|
||||
global allowKeepAlive
|
||||
allowKeepAlive = False
|
Loading…
Reference in New Issue
Block a user