Include host in headers

master
Bob Mottram 2019-07-25 10:13:02 +01:00
parent 26cb3135a5
commit 6feebd6aa2
1 changed files with 12 additions and 2 deletions

View File

@ -84,10 +84,17 @@ def readFollowList(filename: str):
return followlist return followlist
class PubServer(BaseHTTPRequestHandler): class PubServer(BaseHTTPRequestHandler):
def _login_headers(self,fileFormat: str) -> None:
self.send_response(200)
self.send_header('Content-type', fileFormat)
self.send_header('Host', self.server.domainFull)
self.send_header('WWW-Authenticate', 'Basic realm="simple", charset="UTF-8"')
self.end_headers()
def _set_headers(self,fileFormat: str) -> None: def _set_headers(self,fileFormat: str) -> None:
self.send_response(200) self.send_response(200)
self.send_header('Content-type', fileFormat) self.send_header('Content-type', fileFormat)
self.send_header('WWW-Authenticate', 'Basic realm="simple", charset="UTF-8"') self.send_header('Host', self.server.domainFull)
self.end_headers() self.end_headers()
def _404(self) -> None: def _404(self) -> None:
@ -462,7 +469,7 @@ class PubServer(BaseHTTPRequestHandler):
if self.path.startswith('/login'): if self.path.startswith('/login'):
# request basic auth # request basic auth
self._set_headers('text/html') self._login_headers('text/html')
self.wfile.write(htmlLogin(self.server.baseDir).encode('utf-8')) self.wfile.write(htmlLogin(self.server.baseDir).encode('utf-8'))
self.server.GETbusy=False self.server.GETbusy=False
return return
@ -1221,6 +1228,9 @@ def runDaemon(clientToServer: bool,baseDir: str,domain: str, \
httpd = ThreadingHTTPServer(serverAddress, PubServer) httpd = ThreadingHTTPServer(serverAddress, PubServer)
httpd.domain=domain httpd.domain=domain
httpd.port=port httpd.port=port
httpd.domainFull=domain
if port!=80 and port!=443:
httpd.domainFull=domain+':'+str(port)
httpd.httpPrefix=httpPrefix httpd.httpPrefix=httpPrefix
httpd.debug=debug httpd.debug=debug
httpd.federationList=fedList.copy() httpd.federationList=fedList.copy()