/opt/alt/python37/lib/python3.7/site-packages/paste
NameSizeModeActions
auth/-0755rm
cowbell/-0755rm
debug/-0755rm
evalexception/-0755rm
exceptions/-0755rm
util/-0755rm
__pycache__/-0755rm
cascade.py45080644editdlrm
cascade.pyc44750644editdlrm
cascade.pyo44750644editdlrm
cgiapp.py95900644editdlrm
cgiapp.pyc85540644editdlrm
cgiapp.pyo83370644editdlrm
cgitb_catcher.py37520644editdlrm
cgitb_catcher.pyc38510644editdlrm
cgitb_catcher.pyo38510644editdlrm
config.py43120644editdlrm
config.pyc52840644editdlrm
config.pyo52840644editdlrm
errordocument.py137770644editdlrm
errordocument.pyc130800644editdlrm
errordocument.pyo130800644editdlrm
fileapp.py136080644editdlrm
fileapp.pyc133520644editdlrm
fileapp.pyo132180644editdlrm
fixture.py579920644editdlrm
fixture.py.stdlib580750644editdlrm
fixture.pyc607260644editdlrm
fixture.pyo584530644editdlrm
flup_session.py39410644editdlrm
flup_session.pyc39590644editdlrm
flup_session.pyo39590644editdlrm
gzipper.py36920644editdlrm
gzipper.pyc45780644editdlrm
gzipper.pyo45780644editdlrm
httpexceptions.py242220644editdlrm
httpexceptions.pyc283800644editdlrm
httpexceptions.pyo276230644editdlrm
httpheaders.py430900644editdlrm
httpheaders.pyc452740644editdlrm
httpheaders.pyo439740644editdlrm
httpserver.py556620644editdlrm
httpserver.pyc486610644editdlrm
httpserver.pyo479990644editdlrm
lint.py149990644editdlrm
lint.pyc178890644editdlrm
lint.pyo137720644editdlrm
modpython.py79760644editdlrm
modpython.pyc89530644editdlrm
modpython.pyo89530644editdlrm
pony.py22790644editdlrm
pony.pyc27530644editdlrm
pony.pyo27530644editdlrm
progress.py81620644editdlrm
progress.pyc94160644editdlrm
progress.pyo94160644editdlrm
proxy.py101810644editdlrm
proxy.pyc87870644editdlrm
proxy.pyo87870644editdlrm
recursive.py146640644editdlrm
recursive.pyc181410644editdlrm
recursive.pyo178160644editdlrm
registry.py221930644editdlrm
registry.pyc229410644editdlrm
registry.pyo229410644editdlrm
reloader.py60100644editdlrm
reloader.pyc61340644editdlrm
reloader.pyo61340644editdlrm
request.py141450644editdlrm
request.pyc140650644editdlrm
request.pyo139690644editdlrm
response.py76590644editdlrm
response.pyc94680644editdlrm
response.pyo93840644editdlrm
session.py113350644editdlrm
session.pyc120530644editdlrm
session.pyo120530644editdlrm
transaction.py43620644editdlrm
transaction.pyc58570644editdlrm
transaction.pyo58570644editdlrm
translogger.py48120644editdlrm
translogger.pyc43740644editdlrm
translogger.pyo43740644editdlrm
url.py146240644editdlrm
url.pyc185810644editdlrm
url.pyo185810644editdlrm
urlmap.py90320644editdlrm
urlmap.pyc97730644editdlrm
urlmap.pyo96250644editdlrm
urlparser.py264240644editdlrm
urlparser.pyc226700644editdlrm
urlparser.pyo224940644editdlrm
wsgilib.py201340644editdlrm
wsgilib.pyc222360644editdlrm
wsgilib.pyo221800644editdlrm
wsgiwrappers.py221650644editdlrm
wsgiwrappers.pyc244500644editdlrm
wsgiwrappers.pyo244500644editdlrm
Edit: /opt/alt/python37/lib/python3.7/site-packages/paste/response.py (7659B)
# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php """Routines to generate WSGI responses""" ############################################################ ## Headers ############################################################ import warnings class HeaderDict(dict): """ This represents response headers. It handles the headers as a dictionary, with case-insensitive keys. Also there is an ``.add(key, value)`` method, which sets the key, or adds the value to the current value (turning it into a list if necessary). For passing to WSGI there is a ``.headeritems()`` method which is like ``.items()`` but unpacks value that are lists. It also handles encoding -- all headers are encoded in ASCII (if they are unicode). @@: Should that encoding be ISO-8859-1 or UTF-8? I'm not sure what the spec says. """ def __getitem__(self, key): return dict.__getitem__(self, self.normalize(key)) def __setitem__(self, key, value): dict.__setitem__(self, self.normalize(key), value) def __delitem__(self, key): dict.__delitem__(self, self.normalize(key)) def __contains__(self, key): return dict.__contains__(self, self.normalize(key)) has_key = __contains__ def get(self, key, failobj=None): return dict.get(self, self.normalize(key), failobj) def setdefault(self, key, failobj=None): return dict.setdefault(self, self.normalize(key), failobj) def pop(self, key, *args): return dict.pop(self, self.normalize(key), *args) def update(self, other): for key in other: self[self.normalize(key)] = other[key] def normalize(self, key): return str(key).lower().strip() def add(self, key, value): key = self.normalize(key) if key in self: if isinstance(self[key], list): self[key].append(value) else: self[key] = [self[key], value] else: self[key] = value def headeritems(self): result = [] for key, value in self.items(): if isinstance(value, list): for v in value: result.append((key, str(v))) else: result.append((key, str(value))) return result #@classmethod def fromlist(cls, seq): self = cls() for name, value in seq: self.add(name, value) return self fromlist = classmethod(fromlist) def has_header(headers, name): """ Is header named ``name`` present in headers? """ name = name.lower() for header, value in headers: if header.lower() == name: return True return False def header_value(headers, name): """ Returns the header's value, or None if no such header. If a header appears more than once, all the values of the headers are joined with ','. Note that this is consistent /w RFC 2616 section 4.2 which states: It MUST be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma. However, note that the original netscape usage of 'Set-Cookie', especially in MSIE which contains an 'expires' date will is not compatible with this particular concatination method. """ name = name.lower() result = [value for header, value in headers if header.lower() == name] if result: return ','.join(result) else: return None def remove_header(headers, name): """ Removes the named header from the list of headers. Returns the value of that header, or None if no header found. If multiple headers are found, only the last one is returned. """ name = name.lower() i = 0 result = None while i < len(headers): if headers[i][0].lower() == name: result = headers[i][1] del headers[i] continue i += 1 return result def replace_header(headers, name, value): """ Updates the headers replacing the first occurance of the given name with the value provided; asserting that no further occurances happen. Note that this is _not_ the same as remove_header and then append, as two distinct operations (del followed by an append) are not atomic in a threaded environment. Returns the previous header value for the provided name, if any. Clearly one should not use this function with ``set-cookie`` or other names that may have more than one occurance in the headers. """ name = name.lower() i = 0 result = None while i < len(headers): if headers[i][0].lower() == name: assert not result, "two values for the header '%s' found" % name result = headers[i][1] headers[i] = (name, value) i += 1 if not result: headers.append((name, value)) return result ############################################################ ## Deprecated methods ############################################################ def error_body_response(error_code, message, __warn=True): """ Returns a standard HTML response page for an HTTP error. **Note:** Deprecated """ if __warn: warnings.warn( 'wsgilib.error_body_response is deprecated; use the ' 'wsgi_application method on an HTTPException object ' 'instead', DeprecationWarning, 2) return '''\ %(error_code)s

%(error_code)s

%(message)s ''' % { 'error_code': error_code, 'message': message, } def error_response(environ, error_code, message, debug_message=None, __warn=True): """ Returns the status, headers, and body of an error response. Use like: .. code-block:: python status, headers, body = wsgilib.error_response( '301 Moved Permanently', 'Moved to %s' % (url, url)) start_response(status, headers) return [body] **Note:** Deprecated """ if __warn: warnings.warn( 'wsgilib.error_response is deprecated; use the ' 'wsgi_application method on an HTTPException object ' 'instead', DeprecationWarning, 2) if debug_message and environ.get('paste.config', {}).get('debug'): message += '\n\n' % debug_message body = error_body_response(error_code, message, __warn=False) headers = [('content-type', 'text/html'), ('content-length', str(len(body)))] return error_code, headers, body def error_response_app(error_code, message, debug_message=None, __warn=True): """ An application that emits the given error response. **Note:** Deprecated """ if __warn: warnings.warn( 'wsgilib.error_response_app is deprecated; use the ' 'wsgi_application method on an HTTPException object ' 'instead', DeprecationWarning, 2) def application(environ, start_response): status, headers, body = error_response( environ, error_code, message, debug_message=debug_message, __warn=False) start_response(status, headers) return [body] return application