mercurial/hgweb/request.py
changeset 48913 f254fc73d956
parent 48905 7eebe5630bcc
child 48946 642e31cb55f0
equal deleted inserted replaced
48912:a0674e916fb6 48913:f254fc73d956
    75             raise KeyError(b'multiple values for %r' % key)
    75             raise KeyError(b'multiple values for %r' % key)
    76 
    76 
    77         return vals[0]
    77         return vals[0]
    78 
    78 
    79     def asdictoflists(self):
    79     def asdictoflists(self):
    80         return {k: list(v) for k, v in pycompat.iteritems(self._items)}
    80         return {k: list(v) for k, v in self._items.items()}
    81 
    81 
    82 
    82 
    83 @attr.s(frozen=True)
    83 @attr.s(frozen=True)
    84 class parsedrequest(object):
    84 class parsedrequest(object):
    85     """Represents a parsed WSGI request.
    85     """Represents a parsed WSGI request.
   173             return encoding.strtolocal(s)
   173             return encoding.strtolocal(s)
   174         else:
   174         else:
   175             # This is what is documented to be used for os.environ on Unix.
   175             # This is what is documented to be used for os.environ on Unix.
   176             return pycompat.fsencode(s)
   176             return pycompat.fsencode(s)
   177 
   177 
   178     env = {tobytes(k): tobytes(v) for k, v in pycompat.iteritems(env)}
   178     env = {tobytes(k): tobytes(v) for k, v in env.items()}
   179 
   179 
   180     # Some hosting solutions are emulating hgwebdir, and dispatching directly
   180     # Some hosting solutions are emulating hgwebdir, and dispatching directly
   181     # to an hgweb instance using this environment variable.  This was always
   181     # to an hgweb instance using this environment variable.  This was always
   182     # checked prior to d7fd203e36cc; keep doing so to avoid breaking them.
   182     # checked prior to d7fd203e36cc; keep doing so to avoid breaking them.
   183     if not reponame:
   183     if not reponame:
   307 
   307 
   308     # HTTP_* keys contain HTTP request headers. The Headers structure should
   308     # HTTP_* keys contain HTTP request headers. The Headers structure should
   309     # perform case normalization for us. We just rewrite underscore to dash
   309     # perform case normalization for us. We just rewrite underscore to dash
   310     # so keys match what likely went over the wire.
   310     # so keys match what likely went over the wire.
   311     headers = []
   311     headers = []
   312     for k, v in pycompat.iteritems(env):
   312     for k, v in env.items():
   313         if k.startswith(b'HTTP_'):
   313         if k.startswith(b'HTTP_'):
   314             headers.append((k[len(b'HTTP_') :].replace(b'_', b'-'), v))
   314             headers.append((k[len(b'HTTP_') :].replace(b'_', b'-'), v))
   315 
   315 
   316     from . import wsgiheaders  # avoid cycle
   316     from . import wsgiheaders  # avoid cycle
   317 
   317