Content length set to zero on redirects

master
Bob Mottram 2019-08-15 15:50:47 +01:00
parent bbf2ed272b
commit baf49224f2
1 changed files with 7 additions and 4 deletions

View File

@ -134,7 +134,7 @@ def readFollowList(filename: str):
return followlist return followlist
class PubServer(BaseHTTPRequestHandler): class PubServer(BaseHTTPRequestHandler):
protocol_version = 'HTTP/1.0' protocol_version = 'HTTP/1.1'
def _login_headers(self,fileFormat: str,length: int) -> None: def _login_headers(self,fileFormat: str,length: int) -> None:
self.send_response(200) self.send_response(200)
@ -156,12 +156,13 @@ class PubServer(BaseHTTPRequestHandler):
def _redirect_headers(self,redirect: str,cookie: str) -> None: def _redirect_headers(self,redirect: str,cookie: str) -> None:
self.send_response(303) self.send_response(303)
self.send_header('Content-type', 'text/html') #self.send_header('Content-type', 'text/html')
if cookie: if cookie:
self.send_header('Cookie', cookie) self.send_header('Cookie', cookie)
self.send_header('Location', redirect) self.send_header('Location', redirect)
self.send_header('Host', self.server.domainFull) self.send_header('Host', self.server.domainFull)
self.send_header('InstanceID', self.server.instanceId) self.send_header('InstanceID', self.server.instanceId)
self.send_header('Content-Length', '0')
self.end_headers() self.end_headers()
def _404(self) -> None: def _404(self) -> None:
@ -484,6 +485,7 @@ class PubServer(BaseHTTPRequestHandler):
print('DEBUG: authorized='+str(authorized)) print('DEBUG: authorized='+str(authorized))
self.send_response(303) self.send_response(303)
self.send_header('Location', '/login') self.send_header('Location', '/login')
self.send_header('Content-Length', '0')
self.end_headers() self.end_headers()
self.server.GETbusy=False self.server.GETbusy=False
return return
@ -1950,7 +1952,7 @@ class PubServer(BaseHTTPRequestHandler):
del self.server.tokens[loginNickname] del self.server.tokens[loginNickname]
del self.server.salts[loginNickname] del self.server.salts[loginNickname]
self.send_response(303) self.send_response(303)
self.send_header('Content-type', 'text/html; charset=utf-8') self.send_header('Content-Length', '0')
self.send_header('Set-Cookie', 'epicyon=; SameSite=Strict') self.send_header('Set-Cookie', 'epicyon=; SameSite=Strict')
self.send_header('Location', '/login') self.send_header('Location', '/login')
self.end_headers() self.end_headers()
@ -1978,6 +1980,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.tokensLookup[self.server.tokens[loginNickname]]=loginNickname self.server.tokensLookup[self.server.tokens[loginNickname]]=loginNickname
self.send_header('Set-Cookie', 'epicyon='+self.server.tokens[loginNickname]+'; SameSite=Strict') self.send_header('Set-Cookie', 'epicyon='+self.server.tokens[loginNickname]+'; SameSite=Strict')
self.send_header('Location', '/users/'+loginNickname+'/inbox') self.send_header('Location', '/users/'+loginNickname+'/inbox')
self.send_header('Content-Length', '0')
self.end_headers() self.end_headers()
self.server.POSTbusy=False self.server.POSTbusy=False
return return