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:
|
if content != None and autolength == True:
|
||||||
headers["Content-Length"] = str(len(content))
|
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'
|
response = 'HTTP/1.1 ' +status+ '\r\n'
|
||||||
for header in headers:
|
for header in headers:
|
||||||
response += header + ": " +headers[header] + "\r\n"
|
response += header + ": " +headers[header] + "\r\n"
|
||||||
|
@ -12,6 +12,7 @@ pathHandlers = {}
|
|||||||
|
|
||||||
global clientLoopIn
|
global clientLoopIn
|
||||||
def clientLoopIn(self):
|
def clientLoopIn(self):
|
||||||
|
while True:
|
||||||
env = {}
|
env = {}
|
||||||
env["self"] = self
|
env["self"] = self
|
||||||
env["requestTime"] = time.time()
|
env["requestTime"] = time.time()
|
||||||
@ -82,4 +83,8 @@ def clientLoopIn(self):
|
|||||||
env["handler"](env)
|
env["handler"](env)
|
||||||
else:
|
else:
|
||||||
handle404(env)
|
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")
|
indexPath = p(sp,"index")
|
||||||
global readBufferSize
|
global readBufferSize
|
||||||
readBufferSize = 32768
|
readBufferSize = 32768
|
||||||
|
global allowKeepAlive
|
||||||
|
allowKeepAlive = False
|
Loading…
Reference in New Issue
Block a user