Mercurial > hg
diff mercurial/hgweb/server.py @ 37009:5890e5872f36
hgweb: allow defining Server response header for HTTP server
By default, the string contains the Python version. Server
operators may want to change this.
Because we like deterministic tests, we change the test harness
to always set this value to a known string. Various globs over
the server header have now been removed.
# no-check-commit because we add version_string()
Differential Revision: https://phab.mercurial-scm.org/D2840
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 13 Mar 2018 09:45:56 -0700 |
parents | 8e1556ac01bb |
children | a2566597acb5 |
line wrap: on
line diff
--- a/mercurial/hgweb/server.py Tue Mar 13 08:58:52 2018 -0700 +++ b/mercurial/hgweb/server.py Tue Mar 13 09:45:56 2018 -0700 @@ -231,6 +231,11 @@ self.wfile.write('0\r\n\r\n') self.wfile.flush() + def version_string(self): + if self.server.serverheader: + return self.server.serverheader + return httpservermod.basehttprequesthandler.version_string(self) + class _httprequesthandlerssl(_httprequesthandler): """HTTPS handler based on Python's ssl module""" @@ -304,6 +309,8 @@ self.addr, self.port = self.socket.getsockname()[0:2] self.fqaddr = socket.getfqdn(addr[0]) + self.serverheader = ui.config('web', 'server-header') + class IPv6HTTPServer(MercurialHTTPServer): address_family = getattr(socket, 'AF_INET6', None) def __init__(self, *args, **kwargs):