mirror of https://gitlab.com/bashrc2/epicyon
Set redirect headers
parent
c08dd907d2
commit
a77fdc074c
46
daemon.py
46
daemon.py
|
@ -530,37 +530,23 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
print('REDIRECT ERROR: redirect is not an absolute url ' +
|
print('REDIRECT ERROR: redirect is not an absolute url ' +
|
||||||
redirect)
|
redirect)
|
||||||
|
|
||||||
if not httpRedirect:
|
if httpRedirect:
|
||||||
print('Redirect from existing headers: ' + str(self.headers))
|
|
||||||
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-type'] = 'text/html; charset=utf-8'
|
|
||||||
self.headers['Content-Length'] = '0'
|
|
||||||
self.headers['X-Robots-Tag'] = 'noindex'
|
|
||||||
self.do_GET()
|
|
||||||
else:
|
|
||||||
self.send_response(303)
|
self.send_response(303)
|
||||||
if cookie:
|
|
||||||
if not cookie.startswith('SET:'):
|
if cookie:
|
||||||
self.send_header('Cookie', cookie)
|
if not cookie.startswith('SET:'):
|
||||||
else:
|
self.send_header('Cookie', cookie)
|
||||||
self.send_header('Set-Cookie',
|
else:
|
||||||
cookie.replace('SET:', '').strip())
|
self.send_header('Set-Cookie',
|
||||||
self.send_header('Location', redirect)
|
cookie.replace('SET:', '').strip())
|
||||||
self.send_header('Host', callingDomain)
|
self.send_header('Location', redirect)
|
||||||
self.send_header('InstanceID', self.server.instanceId)
|
self.send_header('Host', callingDomain)
|
||||||
self.send_header('Content-Length', '0')
|
self.send_header('InstanceID', self.server.instanceId)
|
||||||
self.send_header('X-Robots-Tag', 'noindex')
|
self.send_header('Content-Length', '0')
|
||||||
self.end_headers()
|
self.send_header('X-Robots-Tag', 'noindex')
|
||||||
|
self.end_headers()
|
||||||
|
if not httpRedirect:
|
||||||
|
self.do_GET()
|
||||||
|
|
||||||
def _httpReturnCode(self, httpCode: int, httpDescription: str) -> None:
|
def _httpReturnCode(self, httpCode: int, httpDescription: str) -> None:
|
||||||
msg = "<html><head></head><body><h1>" + str(httpCode) + " " + \
|
msg = "<html><head></head><body><h1>" + str(httpCode) + " " + \
|
||||||
|
|
Loading…
Reference in New Issue