This is an archive of the discontinued Mercurial Phabricator instance.

hgweb: support constructing URLs from an alternate base URL
ClosedPublic

Authored by indygreg on Mar 12 2018, 5:16 PM.

Details

Summary

The web.baseurl config option allows server operators to define a
custom URL for hosted content.

The way it works today is that hgwebdir parses this config
option into URL components then updates the appropriate
WSGI environment variables so the request "lies" about its
details. For example, SERVER_NAME is updated to reflect the
alternate base URL's hostname.

The WSGI environment should not be modified because WSGI
applications may want to know the original request details (for
debugging, etc).

This commit teaches our request parser about the existence of
an alternate base URL. If defined, the advertised URL and other
self-reflected paths will take the alternate base URL into account.

The hgweb WSGI application didn't use web.baseurl. But hgwebdir
did. We update hgwebdir to alter the environment parsing
accordingly. The old code around environment manipulation
has been removed.

With this change, parserequestfromenv() has grown to a bit
unwieldy. Now that practically everyone is using it, it is
obvious that there is some unused features that can be trimmed.
So look for this in follow-up commits.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Mar 12 2018, 5:16 PM
durin42 accepted this revision.Mar 12 2018, 5:30 PM
This revision is now accepted and ready to land.Mar 12 2018, 5:30 PM
This revision was automatically updated to reflect the committed changes.