comparison mercurial/hgweb/request.py @ 36811: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
comparison
equal deleted inserted replaced
36810:886fba199022 36811:cfb9ef24968c
74 apppath = attr.ib() 74 apppath = attr.ib()
75 # List of path parts to be used for dispatch. 75 # List of path parts to be used for dispatch.
76 dispatchparts = attr.ib() 76 dispatchparts = attr.ib()
77 # URL path component (no query string) used for dispatch. 77 # URL path component (no query string) used for dispatch.
78 dispatchpath = attr.ib() 78 dispatchpath = attr.ib()
79 # Whether there is a path component to this request. This can be true
80 # when ``dispatchpath`` is empty due to REPO_NAME muckery.
81 havepathinfo = attr.ib()
79 # Raw query string (part after "?" in URL). 82 # Raw query string (part after "?" in URL).
80 querystring = attr.ib() 83 querystring = attr.ib()
81 # List of 2-tuples of query string arguments. 84 # List of 2-tuples of query string arguments.
82 querystringlist = attr.ib() 85 querystringlist = attr.ib()
83 # Dict of query string arguments. Values are lists with at least 1 item. 86 # Dict of query string arguments. Values are lists with at least 1 item.
186 return parsedrequest(url=fullurl, baseurl=baseurl, 189 return parsedrequest(url=fullurl, baseurl=baseurl,
187 advertisedurl=advertisedfullurl, 190 advertisedurl=advertisedfullurl,
188 advertisedbaseurl=advertisedbaseurl, 191 advertisedbaseurl=advertisedbaseurl,
189 apppath=apppath, 192 apppath=apppath,
190 dispatchparts=dispatchparts, dispatchpath=dispatchpath, 193 dispatchparts=dispatchparts, dispatchpath=dispatchpath,
194 havepathinfo='PATH_INFO' in env,
191 querystring=querystring, 195 querystring=querystring,
192 querystringlist=querystringlist, 196 querystringlist=querystringlist,
193 querystringdict=querystringdict) 197 querystringdict=querystringdict)
194 198
195 class wsgirequest(object): 199 class wsgirequest(object):