comparison mercurial/hgweb/request.py @ 36854:16292bbda39c

hgweb: store and use request method on parsed request PEP 3333 says that REQUEST_METHOD is always defined. Differential Revision: https://phab.mercurial-scm.org/D2745
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 10 Mar 2018 10:44:56 -0800
parents ed0456fde625
children e85574176467
comparison
equal deleted inserted replaced
36853:ed0456fde625 36854:16292bbda39c
61 61
62 @attr.s(frozen=True) 62 @attr.s(frozen=True)
63 class parsedrequest(object): 63 class parsedrequest(object):
64 """Represents a parsed WSGI request / static HTTP request parameters.""" 64 """Represents a parsed WSGI request / static HTTP request parameters."""
65 65
66 # Request method.
67 method = attr.ib()
66 # Full URL for this request. 68 # Full URL for this request.
67 url = attr.ib() 69 url = attr.ib()
68 # URL without any path components. Just <proto>://<host><port>. 70 # URL without any path components. Just <proto>://<host><port>.
69 baseurl = attr.ib() 71 baseurl = attr.ib()
70 # Advertised URL. Like ``url`` and ``baseurl`` but uses SERVER_NAME instead 72 # Advertised URL. Like ``url`` and ``baseurl`` but uses SERVER_NAME instead
205 # this, since a consumer will either either value to determine how many 207 # this, since a consumer will either either value to determine how many
206 # bytes are available to read. 208 # bytes are available to read.
207 if 'CONTENT_LENGTH' in env and 'HTTP_CONTENT_LENGTH' not in env: 209 if 'CONTENT_LENGTH' in env and 'HTTP_CONTENT_LENGTH' not in env:
208 headers['Content-Length'] = env['CONTENT_LENGTH'] 210 headers['Content-Length'] = env['CONTENT_LENGTH']
209 211
210 return parsedrequest(url=fullurl, baseurl=baseurl, 212 return parsedrequest(method=env['REQUEST_METHOD'],
213 url=fullurl, baseurl=baseurl,
211 advertisedurl=advertisedfullurl, 214 advertisedurl=advertisedfullurl,
212 advertisedbaseurl=advertisedbaseurl, 215 advertisedbaseurl=advertisedbaseurl,
213 apppath=apppath, 216 apppath=apppath,
214 dispatchparts=dispatchparts, dispatchpath=dispatchpath, 217 dispatchparts=dispatchparts, dispatchpath=dispatchpath,
215 havepathinfo='PATH_INFO' in env, 218 havepathinfo='PATH_INFO' in env,