Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/request.py @ 36819:cfb9ef24968c
hgweb: use parsed request to construct query parameters
The way hgweb routes requests is kind of bonkers. If PATH_INFO is
set, we take the URL path after the repository. Otherwise, we take
the first part of the query string before "&" and the part before
";" in that.
We then kinda/sorta treat this as a path and route based on that.
This commit ports that code to use the parsed request object. This
required a new attribute on the parsed request to indicate whether
there is any PATH_INFO.
The new code still feels a bit convoluted for my liking. But we'll
need to rewrite more of the code before a better solution becomes
apparant. This code feels strictly better since we're no longer
doing low-level WSGI manipulation during routing.
Differential Revision: https://phab.mercurial-scm.org/D2739
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 08 Mar 2018 15:37:05 -0800 |
parents | 3c15b84ab66c |
children | f9078c6caeb6 |
line wrap: on
line diff
--- a/mercurial/hgweb/request.py Thu Mar 08 11:33:33 2018 -0800 +++ b/mercurial/hgweb/request.py Thu Mar 08 15:37:05 2018 -0800 @@ -76,6 +76,9 @@ dispatchparts = attr.ib() # URL path component (no query string) used for dispatch. dispatchpath = attr.ib() + # Whether there is a path component to this request. This can be true + # when ``dispatchpath`` is empty due to REPO_NAME muckery. + havepathinfo = attr.ib() # Raw query string (part after "?" in URL). querystring = attr.ib() # List of 2-tuples of query string arguments. @@ -188,6 +191,7 @@ advertisedbaseurl=advertisedbaseurl, apppath=apppath, dispatchparts=dispatchparts, dispatchpath=dispatchpath, + havepathinfo='PATH_INFO' in env, querystring=querystring, querystringlist=querystringlist, querystringdict=querystringdict)