Try redirect without redirecting

main
Bob Mottram 2020-06-19 11:47:25 +01:00
parent 8c1f56e42b
commit c608bd443b
1 changed files with 31 additions and 14 deletions

View File

@ -525,7 +525,27 @@ class PubServer(BaseHTTPRequestHandler):
return False
def _redirect_headers(self, redirect: str, cookie: str,
callingDomain: str) -> None:
callingDomain: str, httpRedirect=False) -> None:
if '://' not in redirect:
print('REDIRECT ERROR: redirect is not an absolute url ' +
redirect)
if not httpRedirect:
self.headers = []
if cookie:
if not cookie.startswith('SET:'):
self.headers['Cookie'] = cookie
else:
self.send_header('Set-Cookie', cookie)
self.Path = redirect.replace(callingDomain, '')
print('Redirect path: ' + self.Path)
self.headers['Location'] = redirect
self.headers['Host'] = callingDomain
self.headers['InstanceID'] = self.server.instanceId
self.headers['Content-Length'] = '0'
self.headers['X-Robots-Tag'] = 'noindex'
self.do_GET()
else:
self.send_response(303)
if cookie:
if not cookie.startswith('SET:'):
@ -533,9 +553,6 @@ class PubServer(BaseHTTPRequestHandler):
else:
self.send_header('Set-Cookie',
cookie.replace('SET:', '').strip())
if '://' not in redirect:
print('REDIRECT ERROR: redirect is not an absolute url ' +
redirect)
self.send_header('Location', redirect)
self.send_header('Host', callingDomain)
self.send_header('InstanceID', self.server.instanceId)