Skip to content

Commit

Permalink
Merge "Allow wsgiref to reconstruct URIs per the WSGI spec"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Apr 29, 2015
2 parents a1b2f0c + f2a7586 commit 62edfcd
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions keystone/common/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import copy
import itertools
import urllib
import wsgiref.util

from oslo_config import cfg
import oslo_i18n
Expand Down Expand Up @@ -227,13 +227,10 @@ def __call__(self, req):
# NOTE(morganfainberg): use the request method to normalize the
# response code between GET and HEAD requests. The HTTP status should
# be the same.
req_method = req.environ['REQUEST_METHOD'].upper()
path = req.environ.get('RAW_PATH_INFO') or req.environ['PATH_INFO']
LOG.info('%(req_method)s %(path)s%(params)s', {
'req_method': req_method,
'path': path,
'params': '?' + urllib.urlencode(req.params) if req.params else ''}
)
LOG.info('%(req_method)s %(uri)s', {
'req_method': req.environ['REQUEST_METHOD'].upper(),
'uri': wsgiref.util.request_uri(req.environ),
})

params = self._normalize_dict(params)

Expand Down Expand Up @@ -272,7 +269,7 @@ def __call__(self, req):

response_code = self._get_response_code(req)
return render_response(body=result, status=response_code,
method=req_method)
method=req.environ['REQUEST_METHOD'])

def _get_response_code(self, req):
req_method = req.environ['REQUEST_METHOD']
Expand Down Expand Up @@ -770,7 +767,7 @@ def render_response(body=None, status=None, headers=None, method=None):
status='%s %s' % status,
headerlist=headers)

if method == 'HEAD':
if method and method.upper() == 'HEAD':
# NOTE(morganfainberg): HEAD requests should return the same status
# as a GET request and same headers (including content-type and
# content-length). The webob.Response object automatically changes
Expand Down

0 comments on commit 62edfcd

Please sign in to comment.