Current File : /home/mmdealscpanel/yummmdeals.com/wsgiref.tar
simple_server.pyc000064400000014133150327210740010143 0ustar00�
{fc@scdZddlmZmZddlZddlZddlmZdZdddd	gZ	d
eZ
dejj�dZ
e
d
e
Zdefd��YZdefd��YZdefd��YZd�Zeed�Zedkr_edde�Zejj�ZdGedGdGedGdGHddlZejd�ej�ej�ndS(s*BaseHTTPServer that implements the Python WSGI protocol (PEP 333, rev 1.21)

This is both an example of how WSGI can be implemented, and a basis for running
simple web applications on a local machine, such as might be done when testing
or debugging an application.  It has not been reviewed for security issues,
however, and we strongly recommend that you use a "real" web server for
production use.

For example usage, see the 'if __name__=="__main__"' block at the end of the
module.  See also the BaseHTTPServer module docs for other API information.
i����(tBaseHTTPRequestHandlert
HTTPServerN(t
SimpleHandlers0.1t
WSGIServertWSGIRequestHandlertdemo_apptmake_serversWSGIServer/sPython/it t
ServerHandlercBseZeZd�ZRS(cCsBz-|jj|jjdd�d|j�Wdtj|�XdS(NRii(trequest_handlertlog_requesttstatustsplitt
bytes_sentRtclose(tself((s-/usr/lib64/python2.7/wsgiref/simple_server.pyRs	$(t__name__t
__module__tsoftware_versiontserver_softwareR(((s-/usr/lib64/python2.7/wsgiref/simple_server.pyRscBs8eZdZdZd�Zd�Zd�Zd�ZRS(s7BaseHTTPServer that implements the Python WSGI protocolcCstj|�|j�dS(s.Override server_bind to store the server name.N(Rtserver_bindt
setup_environ(R((s-/usr/lib64/python2.7/wsgiref/simple_server.pyR.s
cCsYi}|_|j|d<d|d<t|j�|d<d|d<d|d<d|d<dS(	NtSERVER_NAMEsCGI/1.1tGATEWAY_INTERFACEtSERVER_PORTttREMOTE_HOSTtCONTENT_LENGTHtSCRIPT_NAME(tbase_environtserver_nametstrtserver_port(Rtenv((s-/usr/lib64/python2.7/wsgiref/simple_server.pyR3s




cCs|jS(N(tapplication(R((s-/usr/lib64/python2.7/wsgiref/simple_server.pytget_app=scCs
||_dS(N(R"(RR"((s-/usr/lib64/python2.7/wsgiref/simple_server.pytset_app@sN(	RRt__doc__tNoneR"RRR#R$(((s-/usr/lib64/python2.7/wsgiref/simple_server.pyR(s		
	cBs-eZdeZd�Zd�Zd�ZRS(sWSGIServer/c	Cs�|jjj�}|j|d<|j|d<d|jkrY|jjdd�\}}n|jd}}tj|�|d<||d<|j	�}||j
dkr�||d	<n|j
d|d
<|jjdkr�|jj|d<n|jj|d<|jjd�}|r||d
<nx�|jjD]�}|jdd�\}}|jdd�j�}|j�}||kr~q*nd||kr�|d|cd|7<q*||d|<q*W|S(NtSERVER_PROTOCOLtREQUEST_METHODt?iRt	PATH_INFOtQUERY_STRINGiRtREMOTE_ADDRtCONTENT_TYPEscontent-lengthRt:t-t_tHTTP_t,(tserverRtcopytrequest_versiontcommandtpathRturllibtunquotetaddress_stringtclient_addresstheaderst
typeheaderR&ttypet	getheadertreplacetuppertstrip(	RR!R7tquerythosttlengththtktv((s-/usr/lib64/python2.7/wsgiref/simple_server.pytget_environIs8




cCstjS(N(tsyststderr(R((s-/usr/lib64/python2.7/wsgiref/simple_server.pyt
get_stderrnscCs�|jjd�|_t|j�dkrVd|_d|_d|_|jd�dS|j�sfdSt	|j|j
|j�|j��}||_
|j|jj��dS(sHandle a single HTTP requestiiRi�N(trfiletreadlinetraw_requestlinetlentrequestlineR5R6t
send_errort
parse_requestRtwfileRLRIR	trunR3R#(Rthandler((s-/usr/lib64/python2.7/wsgiref/simple_server.pythandleqs			
$	(RRt__version__tserver_versionRIRLRW(((s-/usr/lib64/python2.7/wsgiref/simple_server.pyREs
	%	cCs�ddlm}|�}|dIJ|J|j�}|j�x0|D](\}}||IdIt|�IJqDW|ddg�|j�gS(	Ni����(tStringIOsHello world!t=s200 OKsContent-Types
text/plain(sContent-Types
text/plain(RZtitemstsorttreprtgetvalue(tenvirontstart_responseRZtstdoutRFRGRH((s-/usr/lib64/python2.7/wsgiref/simple_server.pyR�s	

 cCs&|||f|�}|j|�|S(sACreate a new WSGI server listening on `host` and `port` for `app`(R$(RDtporttapptserver_classt
handler_classR3((s-/usr/lib64/python2.7/wsgiref/simple_server.pyR�s
t__main__Ri@sServing HTTP onRcis...shttp://localhost:8000/xyz?abc(R%tBaseHTTPServerRRR8RJtwsgiref.handlersRRXt__all__RYtversionRtsys_versionRRRRRRRthttpdtsockettgetsocknametsat
webbrowsertopenthandle_requesttserver_close(((s-/usr/lib64/python2.7/wsgiref/simple_server.pyt<module>s*
B	


__init__.py000064400000001113150327210740006652 0ustar00"""wsgiref -- a WSGI (PEP 3333) Reference Library

Current Contents:

* util -- Miscellaneous useful functions and wrappers

* headers -- Manage response headers

* handlers -- base classes for server/gateway implementations

* simple_server -- a simple BaseHTTPServer that supports WSGI

* validate -- validation wrapper that sits between an app and a server
  to detect errors in either

To-Do:

* cgi_gateway -- Run WSGI apps under CGI (pending a deployment standard)

* cgi_wrapper -- Run CGI apps under WSGI

* router -- a simple middleware component that handles URL traversal
"""
simple_server.pyo000064400000014133150327210740010157 0ustar00�
{fc@scdZddlmZmZddlZddlZddlmZdZdddd	gZ	d
eZ
dejj�dZ
e
d
e
Zdefd��YZdefd��YZdefd��YZd�Zeed�Zedkr_edde�Zejj�ZdGedGdGedGdGHddlZejd�ej�ej�ndS(s*BaseHTTPServer that implements the Python WSGI protocol (PEP 333, rev 1.21)

This is both an example of how WSGI can be implemented, and a basis for running
simple web applications on a local machine, such as might be done when testing
or debugging an application.  It has not been reviewed for security issues,
however, and we strongly recommend that you use a "real" web server for
production use.

For example usage, see the 'if __name__=="__main__"' block at the end of the
module.  See also the BaseHTTPServer module docs for other API information.
i����(tBaseHTTPRequestHandlert
HTTPServerN(t
SimpleHandlers0.1t
WSGIServertWSGIRequestHandlertdemo_apptmake_serversWSGIServer/sPython/it t
ServerHandlercBseZeZd�ZRS(cCsBz-|jj|jjdd�d|j�Wdtj|�XdS(NRii(trequest_handlertlog_requesttstatustsplitt
bytes_sentRtclose(tself((s-/usr/lib64/python2.7/wsgiref/simple_server.pyRs	$(t__name__t
__module__tsoftware_versiontserver_softwareR(((s-/usr/lib64/python2.7/wsgiref/simple_server.pyRscBs8eZdZdZd�Zd�Zd�Zd�ZRS(s7BaseHTTPServer that implements the Python WSGI protocolcCstj|�|j�dS(s.Override server_bind to store the server name.N(Rtserver_bindt
setup_environ(R((s-/usr/lib64/python2.7/wsgiref/simple_server.pyR.s
cCsYi}|_|j|d<d|d<t|j�|d<d|d<d|d<d|d<dS(	NtSERVER_NAMEsCGI/1.1tGATEWAY_INTERFACEtSERVER_PORTttREMOTE_HOSTtCONTENT_LENGTHtSCRIPT_NAME(tbase_environtserver_nametstrtserver_port(Rtenv((s-/usr/lib64/python2.7/wsgiref/simple_server.pyR3s




cCs|jS(N(tapplication(R((s-/usr/lib64/python2.7/wsgiref/simple_server.pytget_app=scCs
||_dS(N(R"(RR"((s-/usr/lib64/python2.7/wsgiref/simple_server.pytset_app@sN(	RRt__doc__tNoneR"RRR#R$(((s-/usr/lib64/python2.7/wsgiref/simple_server.pyR(s		
	cBs-eZdeZd�Zd�Zd�ZRS(sWSGIServer/c	Cs�|jjj�}|j|d<|j|d<d|jkrY|jjdd�\}}n|jd}}tj|�|d<||d<|j	�}||j
dkr�||d	<n|j
d|d
<|jjdkr�|jj|d<n|jj|d<|jjd�}|r||d
<nx�|jjD]�}|jdd�\}}|jdd�j�}|j�}||kr~q*nd||kr�|d|cd|7<q*||d|<q*W|S(NtSERVER_PROTOCOLtREQUEST_METHODt?iRt	PATH_INFOtQUERY_STRINGiRtREMOTE_ADDRtCONTENT_TYPEscontent-lengthRt:t-t_tHTTP_t,(tserverRtcopytrequest_versiontcommandtpathRturllibtunquotetaddress_stringtclient_addresstheaderst
typeheaderR&ttypet	getheadertreplacetuppertstrip(	RR!R7tquerythosttlengththtktv((s-/usr/lib64/python2.7/wsgiref/simple_server.pytget_environIs8




cCstjS(N(tsyststderr(R((s-/usr/lib64/python2.7/wsgiref/simple_server.pyt
get_stderrnscCs�|jjd�|_t|j�dkrVd|_d|_d|_|jd�dS|j�sfdSt	|j|j
|j�|j��}||_
|j|jj��dS(sHandle a single HTTP requestiiRi�N(trfiletreadlinetraw_requestlinetlentrequestlineR5R6t
send_errort
parse_requestRtwfileRLRIR	trunR3R#(Rthandler((s-/usr/lib64/python2.7/wsgiref/simple_server.pythandleqs			
$	(RRt__version__tserver_versionRIRLRW(((s-/usr/lib64/python2.7/wsgiref/simple_server.pyREs
	%	cCs�ddlm}|�}|dIJ|J|j�}|j�x0|D](\}}||IdIt|�IJqDW|ddg�|j�gS(	Ni����(tStringIOsHello world!t=s200 OKsContent-Types
text/plain(sContent-Types
text/plain(RZtitemstsorttreprtgetvalue(tenvirontstart_responseRZtstdoutRFRGRH((s-/usr/lib64/python2.7/wsgiref/simple_server.pyR�s	

 cCs&|||f|�}|j|�|S(sACreate a new WSGI server listening on `host` and `port` for `app`(R$(RDtporttapptserver_classt
handler_classR3((s-/usr/lib64/python2.7/wsgiref/simple_server.pyR�s
t__main__Ri@sServing HTTP onRcis...shttp://localhost:8000/xyz?abc(R%tBaseHTTPServerRRR8RJtwsgiref.handlersRRXt__all__RYtversionRtsys_versionRRRRRRRthttpdtsockettgetsocknametsat
webbrowsertopenthandle_requesttserver_close(((s-/usr/lib64/python2.7/wsgiref/simple_server.pyt<module>s*
B	


__init__.pyo000064400000001331150327210740007033 0ustar00�
{fc@s
dZdS(sCwsgiref -- a WSGI (PEP 333) Reference Library

Current Contents:

* util -- Miscellaneous useful functions and wrappers

* headers -- Manage response headers

* handlers -- base classes for server/gateway implementations

* simple_server -- a simple BaseHTTPServer that supports WSGI

* validate -- validation wrapper that sits between an app and a server
  to detect errors in either

To-Do:

* cgi_gateway -- Run WSGI apps under CGI (pending a deployment standard)

* cgi_wrapper -- Run CGI apps under WSGI

* router -- a simple middleware component that handles URL traversal
N(t__doc__(((s(/usr/lib64/python2.7/wsgiref/__init__.pyt<module>thandlers.py000064400000052245150327210740006727 0ustar00"""Base classes for server/gateway implementations"""

from .util import FileWrapper, guess_scheme, is_hop_by_hop
from .headers import Headers

import sys, os, time

__all__ = [
    'BaseHandler', 'SimpleHandler', 'BaseCGIHandler', 'CGIHandler',
    'IISCGIHandler', 'read_environ'
]

# Weekday and month names for HTTP date/time formatting; always English!
_weekdayname = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
_monthname = [None, # Dummy so we can use 1-based month numbers
              "Jan", "Feb", "Mar", "Apr", "May", "Jun",
              "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]

def format_date_time(timestamp):
    year, month, day, hh, mm, ss, wd, y, z = time.gmtime(timestamp)
    return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
        _weekdayname[wd], day, _monthname[month], year, hh, mm, ss
    )

_is_request = {
    'SCRIPT_NAME', 'PATH_INFO', 'QUERY_STRING', 'REQUEST_METHOD', 'AUTH_TYPE',
    'CONTENT_TYPE', 'CONTENT_LENGTH', 'HTTPS', 'REMOTE_USER', 'REMOTE_IDENT',
}.__contains__

def _needs_transcode(k):
    return _is_request(k) or k.startswith('HTTP_') or k.startswith('SSL_') \
        or (k.startswith('REDIRECT_') and _needs_transcode(k[9:]))

def read_environ():
    """Read environment, fixing HTTP variables"""
    enc = sys.getfilesystemencoding()
    esc = 'surrogateescape'
    try:
        ''.encode('utf-8', esc)
    except LookupError:
        esc = 'replace'
    environ = {}

    # Take the basic environment from native-unicode os.environ. Attempt to
    # fix up the variables that come from the HTTP request to compensate for
    # the bytes->unicode decoding step that will already have taken place.
    for k, v in os.environ.items():
        if _needs_transcode(k):

            # On win32, the os.environ is natively Unicode. Different servers
            # decode the request bytes using different encodings.
            if sys.platform == 'win32':
                software = os.environ.get('SERVER_SOFTWARE', '').lower()

                # On IIS, the HTTP request will be decoded as UTF-8 as long
                # as the input is a valid UTF-8 sequence. Otherwise it is
                # decoded using the system code page (mbcs), with no way to
                # detect this has happened. Because UTF-8 is the more likely
                # encoding, and mbcs is inherently unreliable (an mbcs string
                # that happens to be valid UTF-8 will not be decoded as mbcs)
                # always recreate the original bytes as UTF-8.
                if software.startswith('microsoft-iis/'):
                    v = v.encode('utf-8').decode('iso-8859-1')

                # Apache mod_cgi writes bytes-as-unicode (as if ISO-8859-1) direct
                # to the Unicode environ. No modification needed.
                elif software.startswith('apache/'):
                    pass

                # Python 3's http.server.CGIHTTPRequestHandler decodes
                # using the urllib.unquote default of UTF-8, amongst other
                # issues.
                elif (
                    software.startswith('simplehttp/')
                    and 'python/3' in software
                ):
                    v = v.encode('utf-8').decode('iso-8859-1')

                # For other servers, guess that they have written bytes to
                # the environ using stdio byte-oriented interfaces, ending up
                # with the system code page.
                else:
                    v = v.encode(enc, 'replace').decode('iso-8859-1')

            # Recover bytes from unicode environ, using surrogate escapes
            # where available (Python 3.1+).
            else:
                v = v.encode(enc, esc).decode('iso-8859-1')

        environ[k] = v
    return environ


class BaseHandler:
    """Manage the invocation of a WSGI application"""

    # Configuration parameters; can override per-subclass or per-instance
    wsgi_version = (1,0)
    wsgi_multithread = True
    wsgi_multiprocess = True
    wsgi_run_once = False

    origin_server = True    # We are transmitting direct to client
    http_version  = "1.0"   # Version that should be used for response
    server_software = None  # String name of server software, if any

    # os_environ is used to supply configuration from the OS environment:
    # by default it's a copy of 'os.environ' as of import time, but you can
    # override this in e.g. your __init__ method.
    os_environ= read_environ()

    # Collaborator classes
    wsgi_file_wrapper = FileWrapper     # set to None to disable
    headers_class = Headers             # must be a Headers-like class

    # Error handling (also per-subclass or per-instance)
    traceback_limit = None  # Print entire traceback to self.get_stderr()
    error_status = "500 Internal Server Error"
    error_headers = [('Content-Type','text/plain')]
    error_body = b"A server error occurred.  Please contact the administrator."

    # State variables (don't mess with these)
    status = result = None
    headers_sent = False
    headers = None
    bytes_sent = 0

    def run(self, application):
        """Invoke the application"""
        # Note to self: don't move the close()!  Asynchronous servers shouldn't
        # call close() from finish_response(), so if you close() anywhere but
        # the double-error branch here, you'll break asynchronous servers by
        # prematurely closing.  Async servers must return from 'run()' without
        # closing if there might still be output to iterate over.
        try:
            self.setup_environ()
            self.result = application(self.environ, self.start_response)
            self.finish_response()
        except (ConnectionAbortedError, BrokenPipeError, ConnectionResetError):
            # We expect the client to close the connection abruptly from time
            # to time.
            return
        except:
            try:
                self.handle_error()
            except:
                # If we get an error handling an error, just give up already!
                self.close()
                raise   # ...and let the actual server figure it out.


    def setup_environ(self):
        """Set up the environment for one request"""

        env = self.environ = self.os_environ.copy()
        self.add_cgi_vars()

        env['wsgi.input']        = self.get_stdin()
        env['wsgi.errors']       = self.get_stderr()
        env['wsgi.version']      = self.wsgi_version
        env['wsgi.run_once']     = self.wsgi_run_once
        env['wsgi.url_scheme']   = self.get_scheme()
        env['wsgi.multithread']  = self.wsgi_multithread
        env['wsgi.multiprocess'] = self.wsgi_multiprocess

        if self.wsgi_file_wrapper is not None:
            env['wsgi.file_wrapper'] = self.wsgi_file_wrapper

        if self.origin_server and self.server_software:
            env.setdefault('SERVER_SOFTWARE',self.server_software)


    def finish_response(self):
        """Send any iterable data, then close self and the iterable

        Subclasses intended for use in asynchronous servers will
        want to redefine this method, such that it sets up callbacks
        in the event loop to iterate over the data, and to call
        'self.close()' once the response is finished.
        """
        try:
            if not self.result_is_file() or not self.sendfile():
                for data in self.result:
                    self.write(data)
                self.finish_content()
        except:
            # Call close() on the iterable returned by the WSGI application
            # in case of an exception.
            if hasattr(self.result, 'close'):
                self.result.close()
            raise
        else:
            # We only call close() when no exception is raised, because it
            # will set status, result, headers, and environ fields to None.
            # See bpo-29183 for more details.
            self.close()


    def get_scheme(self):
        """Return the URL scheme being used"""
        return guess_scheme(self.environ)


    def set_content_length(self):
        """Compute Content-Length or switch to chunked encoding if possible"""
        try:
            blocks = len(self.result)
        except (TypeError,AttributeError,NotImplementedError):
            pass
        else:
            if blocks==1:
                self.headers['Content-Length'] = str(self.bytes_sent)
                return
        # XXX Try for chunked encoding if origin server and client is 1.1


    def cleanup_headers(self):
        """Make any necessary header changes or defaults

        Subclasses can extend this to add other defaults.
        """
        if 'Content-Length' not in self.headers:
            self.set_content_length()

    def start_response(self, status, headers,exc_info=None):
        """'start_response()' callable as specified by PEP 3333"""

        if exc_info:
            try:
                if self.headers_sent:
                    # Re-raise original exception if headers sent
                    raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
            finally:
                exc_info = None        # avoid dangling circular ref
        elif self.headers is not None:
            raise AssertionError("Headers already set!")

        self.status = status
        self.headers = self.headers_class(headers)
        status = self._convert_string_type(status, "Status")
        assert len(status)>=4,"Status must be at least 4 characters"
        assert status[:3].isdigit(), "Status message must begin w/3-digit code"
        assert status[3]==" ", "Status message must have a space after code"

        if __debug__:
            for name, val in headers:
                name = self._convert_string_type(name, "Header name")
                val = self._convert_string_type(val, "Header value")
                assert not is_hop_by_hop(name),\
                       f"Hop-by-hop header, '{name}: {val}', not allowed"

        return self.write

    def _convert_string_type(self, value, title):
        """Convert/check value type."""
        if type(value) is str:
            return value
        raise AssertionError(
            "{0} must be of type str (got {1})".format(title, repr(value))
        )

    def send_preamble(self):
        """Transmit version/status/date/server, via self._write()"""
        if self.origin_server:
            if self.client_is_modern():
                self._write(('HTTP/%s %s\r\n' % (self.http_version,self.status)).encode('iso-8859-1'))
                if 'Date' not in self.headers:
                    self._write(
                        ('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
                    )
                if self.server_software and 'Server' not in self.headers:
                    self._write(('Server: %s\r\n' % self.server_software).encode('iso-8859-1'))
        else:
            self._write(('Status: %s\r\n' % self.status).encode('iso-8859-1'))

    def write(self, data):
        """'write()' callable as specified by PEP 3333"""

        assert type(data) is bytes, \
            "write() argument must be a bytes instance"

        if not self.status:
            raise AssertionError("write() before start_response()")

        elif not self.headers_sent:
            # Before the first output, send the stored headers
            self.bytes_sent = len(data)    # make sure we know content-length
            self.send_headers()
        else:
            self.bytes_sent += len(data)

        # XXX check Content-Length and truncate if too many bytes written?
        self._write(data)
        self._flush()


    def sendfile(self):
        """Platform-specific file transmission

        Override this method in subclasses to support platform-specific
        file transmission.  It is only called if the application's
        return iterable ('self.result') is an instance of
        'self.wsgi_file_wrapper'.

        This method should return a true value if it was able to actually
        transmit the wrapped file-like object using a platform-specific
        approach.  It should return a false value if normal iteration
        should be used instead.  An exception can be raised to indicate
        that transmission was attempted, but failed.

        NOTE: this method should call 'self.send_headers()' if
        'self.headers_sent' is false and it is going to attempt direct
        transmission of the file.
        """
        return False   # No platform-specific transmission by default


    def finish_content(self):
        """Ensure headers and content have both been sent"""
        if not self.headers_sent:
            # Only zero Content-Length if not set by the application (so
            # that HEAD requests can be satisfied properly, see #3839)
            self.headers.setdefault('Content-Length', "0")
            self.send_headers()
        else:
            pass # XXX check if content-length was too short?

    def close(self):
        """Close the iterable (if needed) and reset all instance vars

        Subclasses may want to also drop the client connection.
        """
        try:
            if hasattr(self.result,'close'):
                self.result.close()
        finally:
            self.result = self.headers = self.status = self.environ = None
            self.bytes_sent = 0; self.headers_sent = False


    def send_headers(self):
        """Transmit headers to the client, via self._write()"""
        self.cleanup_headers()
        self.headers_sent = True
        if not self.origin_server or self.client_is_modern():
            self.send_preamble()
            self._write(bytes(self.headers))


    def result_is_file(self):
        """True if 'self.result' is an instance of 'self.wsgi_file_wrapper'"""
        wrapper = self.wsgi_file_wrapper
        return wrapper is not None and isinstance(self.result,wrapper)


    def client_is_modern(self):
        """True if client can accept status and headers"""
        return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'


    def log_exception(self,exc_info):
        """Log the 'exc_info' tuple in the server log

        Subclasses may override to retarget the output or change its format.
        """
        try:
            from traceback import print_exception
            stderr = self.get_stderr()
            print_exception(
                exc_info[0], exc_info[1], exc_info[2],
                self.traceback_limit, stderr
            )
            stderr.flush()
        finally:
            exc_info = None

    def handle_error(self):
        """Log current error, and send error output to client if possible"""
        self.log_exception(sys.exc_info())
        if not self.headers_sent:
            self.result = self.error_output(self.environ, self.start_response)
            self.finish_response()
        # XXX else: attempt advanced recovery techniques for HTML or text?

    def error_output(self, environ, start_response):
        """WSGI mini-app to create error output

        By default, this just uses the 'error_status', 'error_headers',
        and 'error_body' attributes to generate an output page.  It can
        be overridden in a subclass to dynamically generate diagnostics,
        choose an appropriate message for the user's preferred language, etc.

        Note, however, that it's not recommended from a security perspective to
        spit out diagnostics to any old user; ideally, you should have to do
        something special to enable diagnostic output, which is why we don't
        include any here!
        """
        start_response(self.error_status,self.error_headers[:],sys.exc_info())
        return [self.error_body]


    # Pure abstract methods; *must* be overridden in subclasses

    def _write(self,data):
        """Override in subclass to buffer data for send to client

        It's okay if this method actually transmits the data; BaseHandler
        just separates write and flush operations for greater efficiency
        when the underlying system actually has such a distinction.
        """
        raise NotImplementedError

    def _flush(self):
        """Override in subclass to force sending of recent '_write()' calls

        It's okay if this method is a no-op (i.e., if '_write()' actually
        sends the data.
        """
        raise NotImplementedError

    def get_stdin(self):
        """Override in subclass to return suitable 'wsgi.input'"""
        raise NotImplementedError

    def get_stderr(self):
        """Override in subclass to return suitable 'wsgi.errors'"""
        raise NotImplementedError

    def add_cgi_vars(self):
        """Override in subclass to insert CGI variables in 'self.environ'"""
        raise NotImplementedError


class SimpleHandler(BaseHandler):
    """Handler that's just initialized with streams, environment, etc.

    This handler subclass is intended for synchronous HTTP/1.0 origin servers,
    and handles sending the entire response output, given the correct inputs.

    Usage::

        handler = SimpleHandler(
            inp,out,err,env, multithread=False, multiprocess=True
        )
        handler.run(app)"""

    def __init__(self,stdin,stdout,stderr,environ,
        multithread=True, multiprocess=False
    ):
        self.stdin = stdin
        self.stdout = stdout
        self.stderr = stderr
        self.base_env = environ
        self.wsgi_multithread = multithread
        self.wsgi_multiprocess = multiprocess

    def get_stdin(self):
        return self.stdin

    def get_stderr(self):
        return self.stderr

    def add_cgi_vars(self):
        self.environ.update(self.base_env)

    def _write(self,data):
        result = self.stdout.write(data)
        if result is None or result == len(data):
            return
        from warnings import warn
        warn("SimpleHandler.stdout.write() should not do partial writes",
            DeprecationWarning)
        while True:
            data = data[result:]
            if not data:
                break
            result = self.stdout.write(data)

    def _flush(self):
        self.stdout.flush()
        self._flush = self.stdout.flush


class BaseCGIHandler(SimpleHandler):

    """CGI-like systems using input/output/error streams and environ mapping

    Usage::

        handler = BaseCGIHandler(inp,out,err,env)
        handler.run(app)

    This handler class is useful for gateway protocols like ReadyExec and
    FastCGI, that have usable input/output/error streams and an environment
    mapping.  It's also the base class for CGIHandler, which just uses
    sys.stdin, os.environ, and so on.

    The constructor also takes keyword arguments 'multithread' and
    'multiprocess' (defaulting to 'True' and 'False' respectively) to control
    the configuration sent to the application.  It sets 'origin_server' to
    False (to enable CGI-like output), and assumes that 'wsgi.run_once' is
    False.
    """

    origin_server = False


class CGIHandler(BaseCGIHandler):

    """CGI-based invocation via sys.stdin/stdout/stderr and os.environ

    Usage::

        CGIHandler().run(app)

    The difference between this class and BaseCGIHandler is that it always
    uses 'wsgi.run_once' of 'True', 'wsgi.multithread' of 'False', and
    'wsgi.multiprocess' of 'True'.  It does not take any initialization
    parameters, but always uses 'sys.stdin', 'os.environ', and friends.

    If you need to override any of these parameters, use BaseCGIHandler
    instead.
    """

    wsgi_run_once = True
    # Do not allow os.environ to leak between requests in Google App Engine
    # and other multi-run CGI use cases.  This is not easily testable.
    # See http://bugs.python.org/issue7250
    os_environ = {}

    def __init__(self):
        BaseCGIHandler.__init__(
            self, sys.stdin.buffer, sys.stdout.buffer, sys.stderr,
            read_environ(), multithread=False, multiprocess=True
        )


class IISCGIHandler(BaseCGIHandler):
    """CGI-based invocation with workaround for IIS path bug

    This handler should be used in preference to CGIHandler when deploying on
    Microsoft IIS without having set the config allowPathInfo option (IIS>=7)
    or metabase allowPathInfoForScriptMappings (IIS<7).
    """
    wsgi_run_once = True
    os_environ = {}

    # By default, IIS gives a PATH_INFO that duplicates the SCRIPT_NAME at
    # the front, causing problems for WSGI applications that wish to implement
    # routing. This handler strips any such duplicated path.

    # IIS can be configured to pass the correct PATH_INFO, but this causes
    # another bug where PATH_TRANSLATED is wrong. Luckily this variable is
    # rarely used and is not guaranteed by WSGI. On IIS<7, though, the
    # setting can only be made on a vhost level, affecting all other script
    # mappings, many of which break when exposed to the PATH_TRANSLATED bug.
    # For this reason IIS<7 is almost never deployed with the fix. (Even IIS7
    # rarely uses it because there is still no UI for it.)

    # There is no way for CGI code to tell whether the option was set, so a
    # separate handler class is provided.
    def __init__(self):
        environ= read_environ()
        path = environ.get('PATH_INFO', '')
        script = environ.get('SCRIPT_NAME', '')
        if (path+'/').startswith(script+'/'):
            environ['PATH_INFO'] = path[len(script):]
        BaseCGIHandler.__init__(
            self, sys.stdin.buffer, sys.stdout.buffer, sys.stderr,
            environ, multithread=False, multiprocess=True
        )
util.py000064400000013333150327210740006077 0ustar00"""Miscellaneous WSGI-related Utilities"""

import posixpath

__all__ = [
    'FileWrapper', 'guess_scheme', 'application_uri', 'request_uri',
    'shift_path_info', 'setup_testing_defaults',
]


class FileWrapper:
    """Wrapper to convert file-like objects to iterables"""

    def __init__(self, filelike, blksize=8192):
        self.filelike = filelike
        self.blksize = blksize
        if hasattr(filelike,'close'):
            self.close = filelike.close

    def __getitem__(self,key):
        import warnings
        warnings.warn(
            "FileWrapper's __getitem__ method ignores 'key' parameter. "
            "Use iterator protocol instead.",
            DeprecationWarning,
            stacklevel=2
        )
        data = self.filelike.read(self.blksize)
        if data:
            return data
        raise IndexError

    def __iter__(self):
        return self

    def __next__(self):
        data = self.filelike.read(self.blksize)
        if data:
            return data
        raise StopIteration

def guess_scheme(environ):
    """Return a guess for whether 'wsgi.url_scheme' should be 'http' or 'https'
    """
    if environ.get("HTTPS") in ('yes','on','1'):
        return 'https'
    else:
        return 'http'

def application_uri(environ):
    """Return the application's base URI (no PATH_INFO or QUERY_STRING)"""
    url = environ['wsgi.url_scheme']+'://'
    from urllib.parse import quote

    if environ.get('HTTP_HOST'):
        url += environ['HTTP_HOST']
    else:
        url += environ['SERVER_NAME']

        if environ['wsgi.url_scheme'] == 'https':
            if environ['SERVER_PORT'] != '443':
                url += ':' + environ['SERVER_PORT']
        else:
            if environ['SERVER_PORT'] != '80':
                url += ':' + environ['SERVER_PORT']

    url += quote(environ.get('SCRIPT_NAME') or '/', encoding='latin1')
    return url

def request_uri(environ, include_query=True):
    """Return the full request URI, optionally including the query string"""
    url = application_uri(environ)
    from urllib.parse import quote
    path_info = quote(environ.get('PATH_INFO',''), safe='/;=,', encoding='latin1')
    if not environ.get('SCRIPT_NAME'):
        url += path_info[1:]
    else:
        url += path_info
    if include_query and environ.get('QUERY_STRING'):
        url += '?' + environ['QUERY_STRING']
    return url

def shift_path_info(environ):
    """Shift a name from PATH_INFO to SCRIPT_NAME, returning it

    If there are no remaining path segments in PATH_INFO, return None.
    Note: 'environ' is modified in-place; use a copy if you need to keep
    the original PATH_INFO or SCRIPT_NAME.

    Note: when PATH_INFO is just a '/', this returns '' and appends a trailing
    '/' to SCRIPT_NAME, even though empty path segments are normally ignored,
    and SCRIPT_NAME doesn't normally end in a '/'.  This is intentional
    behavior, to ensure that an application can tell the difference between
    '/x' and '/x/' when traversing to objects.
    """
    path_info = environ.get('PATH_INFO','')
    if not path_info:
        return None

    path_parts = path_info.split('/')
    path_parts[1:-1] = [p for p in path_parts[1:-1] if p and p != '.']
    name = path_parts[1]
    del path_parts[1]

    script_name = environ.get('SCRIPT_NAME','')
    script_name = posixpath.normpath(script_name+'/'+name)
    if script_name.endswith('/'):
        script_name = script_name[:-1]
    if not name and not script_name.endswith('/'):
        script_name += '/'

    environ['SCRIPT_NAME'] = script_name
    environ['PATH_INFO']   = '/'.join(path_parts)

    # Special case: '/.' on PATH_INFO doesn't get stripped,
    # because we don't strip the last element of PATH_INFO
    # if there's only one path part left.  Instead of fixing this
    # above, we fix it here so that PATH_INFO gets normalized to
    # an empty string in the environ.
    if name=='.':
        name = None
    return name

def setup_testing_defaults(environ):
    """Update 'environ' with trivial defaults for testing purposes

    This adds various parameters required for WSGI, including HTTP_HOST,
    SERVER_NAME, SERVER_PORT, REQUEST_METHOD, SCRIPT_NAME, PATH_INFO,
    and all of the wsgi.* variables.  It only supplies default values,
    and does not replace any existing settings for these variables.

    This routine is intended to make it easier for unit tests of WSGI
    servers and applications to set up dummy environments.  It should *not*
    be used by actual WSGI servers or applications, since the data is fake!
    """

    environ.setdefault('SERVER_NAME','127.0.0.1')
    environ.setdefault('SERVER_PROTOCOL','HTTP/1.0')

    environ.setdefault('HTTP_HOST',environ['SERVER_NAME'])
    environ.setdefault('REQUEST_METHOD','GET')

    if 'SCRIPT_NAME' not in environ and 'PATH_INFO' not in environ:
        environ.setdefault('SCRIPT_NAME','')
        environ.setdefault('PATH_INFO','/')

    environ.setdefault('wsgi.version', (1,0))
    environ.setdefault('wsgi.run_once', 0)
    environ.setdefault('wsgi.multithread', 0)
    environ.setdefault('wsgi.multiprocess', 0)

    from io import StringIO, BytesIO
    environ.setdefault('wsgi.input', BytesIO())
    environ.setdefault('wsgi.errors', StringIO())
    environ.setdefault('wsgi.url_scheme',guess_scheme(environ))

    if environ['wsgi.url_scheme']=='http':
        environ.setdefault('SERVER_PORT', '80')
    elif environ['wsgi.url_scheme']=='https':
        environ.setdefault('SERVER_PORT', '443')



_hoppish = {
    'connection', 'keep-alive', 'proxy-authenticate',
    'proxy-authorization', 'te', 'trailers', 'transfer-encoding',
    'upgrade'
}.__contains__

def is_hop_by_hop(header_name):
    """Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header"""
    return _hoppish(header_name.lower())
simple_server.py000064400000012063150327210740010000 0ustar00"""BaseHTTPServer that implements the Python WSGI protocol (PEP 3333)

This is both an example of how WSGI can be implemented, and a basis for running
simple web applications on a local machine, such as might be done when testing
or debugging an application.  It has not been reviewed for security issues,
however, and we strongly recommend that you use a "real" web server for
production use.

For example usage, see the 'if __name__=="__main__"' block at the end of the
module.  See also the BaseHTTPServer module docs for other API information.
"""

from http.server import BaseHTTPRequestHandler, HTTPServer
import sys
import urllib.parse
from wsgiref.handlers import SimpleHandler
from platform import python_implementation

__version__ = "0.2"
__all__ = ['WSGIServer', 'WSGIRequestHandler', 'demo_app', 'make_server']


server_version = "WSGIServer/" + __version__
sys_version = python_implementation() + "/" + sys.version.split()[0]
software_version = server_version + ' ' + sys_version


class ServerHandler(SimpleHandler):

    server_software = software_version

    def close(self):
        try:
            self.request_handler.log_request(
                self.status.split(' ',1)[0], self.bytes_sent
            )
        finally:
            SimpleHandler.close(self)



class WSGIServer(HTTPServer):

    """BaseHTTPServer that implements the Python WSGI protocol"""

    application = None

    def server_bind(self):
        """Override server_bind to store the server name."""
        HTTPServer.server_bind(self)
        self.setup_environ()

    def setup_environ(self):
        # Set up base environment
        env = self.base_environ = {}
        env['SERVER_NAME'] = self.server_name
        env['GATEWAY_INTERFACE'] = 'CGI/1.1'
        env['SERVER_PORT'] = str(self.server_port)
        env['REMOTE_HOST']=''
        env['CONTENT_LENGTH']=''
        env['SCRIPT_NAME'] = ''

    def get_app(self):
        return self.application

    def set_app(self,application):
        self.application = application



class WSGIRequestHandler(BaseHTTPRequestHandler):

    server_version = "WSGIServer/" + __version__

    def get_environ(self):
        env = self.server.base_environ.copy()
        env['SERVER_PROTOCOL'] = self.request_version
        env['SERVER_SOFTWARE'] = self.server_version
        env['REQUEST_METHOD'] = self.command
        if '?' in self.path:
            path,query = self.path.split('?',1)
        else:
            path,query = self.path,''

        env['PATH_INFO'] = urllib.parse.unquote(path, 'iso-8859-1')
        env['QUERY_STRING'] = query

        host = self.address_string()
        if host != self.client_address[0]:
            env['REMOTE_HOST'] = host
        env['REMOTE_ADDR'] = self.client_address[0]

        if self.headers.get('content-type') is None:
            env['CONTENT_TYPE'] = self.headers.get_content_type()
        else:
            env['CONTENT_TYPE'] = self.headers['content-type']

        length = self.headers.get('content-length')
        if length:
            env['CONTENT_LENGTH'] = length

        for k, v in self.headers.items():
            k=k.replace('-','_').upper(); v=v.strip()
            if k in env:
                continue                    # skip content length, type,etc.
            if 'HTTP_'+k in env:
                env['HTTP_'+k] += ','+v     # comma-separate multiple headers
            else:
                env['HTTP_'+k] = v
        return env

    def get_stderr(self):
        return sys.stderr

    def handle(self):
        """Handle a single HTTP request"""

        self.raw_requestline = self.rfile.readline(65537)
        if len(self.raw_requestline) > 65536:
            self.requestline = ''
            self.request_version = ''
            self.command = ''
            self.send_error(414)
            return

        if not self.parse_request(): # An error code has been sent, just exit
            return

        handler = ServerHandler(
            self.rfile, self.wfile, self.get_stderr(), self.get_environ(),
            multithread=False,
        )
        handler.request_handler = self      # backpointer for logging
        handler.run(self.server.get_app())



def demo_app(environ,start_response):
    from io import StringIO
    stdout = StringIO()
    print("Hello world!", file=stdout)
    print(file=stdout)
    h = sorted(environ.items())
    for k,v in h:
        print(k,'=',repr(v), file=stdout)
    start_response("200 OK", [('Content-Type','text/plain; charset=utf-8')])
    return [stdout.getvalue().encode("utf-8")]


def make_server(
    host, port, app, server_class=WSGIServer, handler_class=WSGIRequestHandler
):
    """Create a new WSGI server listening on `host` and `port` for `app`"""
    server = server_class((host, port), handler_class)
    server.set_app(app)
    return server


if __name__ == '__main__':
    with make_server('', 8000, demo_app) as httpd:
        sa = httpd.socket.getsockname()
        print("Serving HTTP on", sa[0], "port", sa[1], "...")
        import webbrowser
        webbrowser.open('http://localhost:8000/xyz?abc')
        httpd.handle_request()  # serve one request, then exit
validate.py000064400000035373150327210740006723 0ustar00# (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
# Also licenced under the Apache License, 2.0: http://opensource.org/licenses/apache2.0.php
# Licensed to PSF under a Contributor Agreement
"""
Middleware to check for obedience to the WSGI specification.

Some of the things this checks:

* Signature of the application and start_response (including that
  keyword arguments are not used).

* Environment checks:

  - Environment is a dictionary (and not a subclass).

  - That all the required keys are in the environment: REQUEST_METHOD,
    SERVER_NAME, SERVER_PORT, wsgi.version, wsgi.input, wsgi.errors,
    wsgi.multithread, wsgi.multiprocess, wsgi.run_once

  - That HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH are not in the
    environment (these headers should appear as CONTENT_LENGTH and
    CONTENT_TYPE).

  - Warns if QUERY_STRING is missing, as the cgi module acts
    unpredictably in that case.

  - That CGI-style variables (that don't contain a .) have
    (non-unicode) string values

  - That wsgi.version is a tuple

  - That wsgi.url_scheme is 'http' or 'https' (@@: is this too
    restrictive?)

  - Warns if the REQUEST_METHOD is not known (@@: probably too
    restrictive).

  - That SCRIPT_NAME and PATH_INFO are empty or start with /

  - That at least one of SCRIPT_NAME or PATH_INFO are set.

  - That CONTENT_LENGTH is a positive integer.

  - That SCRIPT_NAME is not '/' (it should be '', and PATH_INFO should
    be '/').

  - That wsgi.input has the methods read, readline, readlines, and
    __iter__

  - That wsgi.errors has the methods flush, write, writelines

* The status is a string, contains a space, starts with an integer,
  and that integer is in range (> 100).

* That the headers is a list (not a subclass, not another kind of
  sequence).

* That the items of the headers are tuples of strings.

* That there is no 'status' header (that is used in CGI, but not in
  WSGI).

* That the headers don't contain newlines or colons, end in _ or -, or
  contain characters codes below 037.

* That Content-Type is given if there is content (CGI often has a
  default content type, but WSGI does not).

* That no Content-Type is given when there is no content (@@: is this
  too restrictive?)

* That the exc_info argument to start_response is a tuple or None.

* That all calls to the writer are with strings, and no other methods
  on the writer are accessed.

* That wsgi.input is used properly:

  - .read() is called with exactly one argument

  - That it returns a string

  - That readline, readlines, and __iter__ return strings

  - That .close() is not called

  - No other methods are provided

* That wsgi.errors is used properly:

  - .write() and .writelines() is called with a string

  - That .close() is not called, and no other methods are provided.

* The response iterator:

  - That it is not a string (it should be a list of a single string; a
    string will work, but perform horribly).

  - That .__next__() returns a string

  - That the iterator is not iterated over until start_response has
    been called (that can signal either a server or application
    error).

  - That .close() is called (doesn't raise exception, only prints to
    sys.stderr, because we only know it isn't called when the object
    is garbage collected).
"""
__all__ = ['validator']


import re
import sys
import warnings

header_re = re.compile(r'^[a-zA-Z][a-zA-Z0-9\-_]*$')
bad_header_value_re = re.compile(r'[\000-\037]')

class WSGIWarning(Warning):
    """
    Raised in response to WSGI-spec-related warnings
    """

def assert_(cond, *args):
    if not cond:
        raise AssertionError(*args)

def check_string_type(value, title):
    if type (value) is str:
        return value
    raise AssertionError(
        "{0} must be of type str (got {1})".format(title, repr(value)))

def validator(application):

    """
    When applied between a WSGI server and a WSGI application, this
    middleware will check for WSGI compliancy on a number of levels.
    This middleware does not modify the request or response in any
    way, but will raise an AssertionError if anything seems off
    (except for a failure to close the application iterator, which
    will be printed to stderr -- there's no way to raise an exception
    at that point).
    """

    def lint_app(*args, **kw):
        assert_(len(args) == 2, "Two arguments required")
        assert_(not kw, "No keyword arguments allowed")
        environ, start_response = args

        check_environ(environ)

        # We use this to check if the application returns without
        # calling start_response:
        start_response_started = []

        def start_response_wrapper(*args, **kw):
            assert_(len(args) == 2 or len(args) == 3, (
                "Invalid number of arguments: %s" % (args,)))
            assert_(not kw, "No keyword arguments allowed")
            status = args[0]
            headers = args[1]
            if len(args) == 3:
                exc_info = args[2]
            else:
                exc_info = None

            check_status(status)
            check_headers(headers)
            check_content_type(status, headers)
            check_exc_info(exc_info)

            start_response_started.append(None)
            return WriteWrapper(start_response(*args))

        environ['wsgi.input'] = InputWrapper(environ['wsgi.input'])
        environ['wsgi.errors'] = ErrorWrapper(environ['wsgi.errors'])

        iterator = application(environ, start_response_wrapper)
        assert_(iterator is not None and iterator != False,
            "The application must return an iterator, if only an empty list")

        check_iterator(iterator)

        return IteratorWrapper(iterator, start_response_started)

    return lint_app

class InputWrapper:

    def __init__(self, wsgi_input):
        self.input = wsgi_input

    def read(self, *args):
        assert_(len(args) == 1)
        v = self.input.read(*args)
        assert_(type(v) is bytes)
        return v

    def readline(self, *args):
        assert_(len(args) <= 1)
        v = self.input.readline(*args)
        assert_(type(v) is bytes)
        return v

    def readlines(self, *args):
        assert_(len(args) <= 1)
        lines = self.input.readlines(*args)
        assert_(type(lines) is list)
        for line in lines:
            assert_(type(line) is bytes)
        return lines

    def __iter__(self):
        while 1:
            line = self.readline()
            if not line:
                return
            yield line

    def close(self):
        assert_(0, "input.close() must not be called")

class ErrorWrapper:

    def __init__(self, wsgi_errors):
        self.errors = wsgi_errors

    def write(self, s):
        assert_(type(s) is str)
        self.errors.write(s)

    def flush(self):
        self.errors.flush()

    def writelines(self, seq):
        for line in seq:
            self.write(line)

    def close(self):
        assert_(0, "errors.close() must not be called")

class WriteWrapper:

    def __init__(self, wsgi_writer):
        self.writer = wsgi_writer

    def __call__(self, s):
        assert_(type(s) is bytes)
        self.writer(s)

class PartialIteratorWrapper:

    def __init__(self, wsgi_iterator):
        self.iterator = wsgi_iterator

    def __iter__(self):
        # We want to make sure __iter__ is called
        return IteratorWrapper(self.iterator, None)

class IteratorWrapper:

    def __init__(self, wsgi_iterator, check_start_response):
        self.original_iterator = wsgi_iterator
        self.iterator = iter(wsgi_iterator)
        self.closed = False
        self.check_start_response = check_start_response

    def __iter__(self):
        return self

    def __next__(self):
        assert_(not self.closed,
            "Iterator read after closed")
        v = next(self.iterator)
        if type(v) is not bytes:
            assert_(False, "Iterator yielded non-bytestring (%r)" % (v,))
        if self.check_start_response is not None:
            assert_(self.check_start_response,
                "The application returns and we started iterating over its body, but start_response has not yet been called")
            self.check_start_response = None
        return v

    def close(self):
        self.closed = True
        if hasattr(self.original_iterator, 'close'):
            self.original_iterator.close()

    def __del__(self):
        if not self.closed:
            sys.stderr.write(
                "Iterator garbage collected without being closed")
        assert_(self.closed,
            "Iterator garbage collected without being closed")

def check_environ(environ):
    assert_(type(environ) is dict,
        "Environment is not of the right type: %r (environment: %r)"
        % (type(environ), environ))

    for key in ['REQUEST_METHOD', 'SERVER_NAME', 'SERVER_PORT',
                'wsgi.version', 'wsgi.input', 'wsgi.errors',
                'wsgi.multithread', 'wsgi.multiprocess',
                'wsgi.run_once']:
        assert_(key in environ,
            "Environment missing required key: %r" % (key,))

    for key in ['HTTP_CONTENT_TYPE', 'HTTP_CONTENT_LENGTH']:
        assert_(key not in environ,
            "Environment should not have the key: %s "
            "(use %s instead)" % (key, key[5:]))

    if 'QUERY_STRING' not in environ:
        warnings.warn(
            'QUERY_STRING is not in the WSGI environment; the cgi '
            'module will use sys.argv when this variable is missing, '
            'so application errors are more likely',
            WSGIWarning)

    for key in environ.keys():
        if '.' in key:
            # Extension, we don't care about its type
            continue
        assert_(type(environ[key]) is str,
            "Environmental variable %s is not a string: %r (value: %r)"
            % (key, type(environ[key]), environ[key]))

    assert_(type(environ['wsgi.version']) is tuple,
        "wsgi.version should be a tuple (%r)" % (environ['wsgi.version'],))
    assert_(environ['wsgi.url_scheme'] in ('http', 'https'),
        "wsgi.url_scheme unknown: %r" % environ['wsgi.url_scheme'])

    check_input(environ['wsgi.input'])
    check_errors(environ['wsgi.errors'])

    # @@: these need filling out:
    if environ['REQUEST_METHOD'] not in (
        'GET', 'HEAD', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE', 'TRACE'):
        warnings.warn(
            "Unknown REQUEST_METHOD: %r" % environ['REQUEST_METHOD'],
            WSGIWarning)

    assert_(not environ.get('SCRIPT_NAME')
            or environ['SCRIPT_NAME'].startswith('/'),
        "SCRIPT_NAME doesn't start with /: %r" % environ['SCRIPT_NAME'])
    assert_(not environ.get('PATH_INFO')
            or environ['PATH_INFO'].startswith('/'),
        "PATH_INFO doesn't start with /: %r" % environ['PATH_INFO'])
    if environ.get('CONTENT_LENGTH'):
        assert_(int(environ['CONTENT_LENGTH']) >= 0,
            "Invalid CONTENT_LENGTH: %r" % environ['CONTENT_LENGTH'])

    if not environ.get('SCRIPT_NAME'):
        assert_('PATH_INFO' in environ,
            "One of SCRIPT_NAME or PATH_INFO are required (PATH_INFO "
            "should at least be '/' if SCRIPT_NAME is empty)")
    assert_(environ.get('SCRIPT_NAME') != '/',
        "SCRIPT_NAME cannot be '/'; it should instead be '', and "
        "PATH_INFO should be '/'")

def check_input(wsgi_input):
    for attr in ['read', 'readline', 'readlines', '__iter__']:
        assert_(hasattr(wsgi_input, attr),
            "wsgi.input (%r) doesn't have the attribute %s"
            % (wsgi_input, attr))

def check_errors(wsgi_errors):
    for attr in ['flush', 'write', 'writelines']:
        assert_(hasattr(wsgi_errors, attr),
            "wsgi.errors (%r) doesn't have the attribute %s"
            % (wsgi_errors, attr))

def check_status(status):
    status = check_string_type(status, "Status")
    # Implicitly check that we can turn it into an integer:
    status_code = status.split(None, 1)[0]
    assert_(len(status_code) == 3,
        "Status codes must be three characters: %r" % status_code)
    status_int = int(status_code)
    assert_(status_int >= 100, "Status code is invalid: %r" % status_int)
    if len(status) < 4 or status[3] != ' ':
        warnings.warn(
            "The status string (%r) should be a three-digit integer "
            "followed by a single space and a status explanation"
            % status, WSGIWarning)

def check_headers(headers):
    assert_(type(headers) is list,
        "Headers (%r) must be of type list: %r"
        % (headers, type(headers)))
    for item in headers:
        assert_(type(item) is tuple,
            "Individual headers (%r) must be of type tuple: %r"
            % (item, type(item)))
        assert_(len(item) == 2)
        name, value = item
        name = check_string_type(name, "Header name")
        value = check_string_type(value, "Header value")
        assert_(name.lower() != 'status',
            "The Status header cannot be used; it conflicts with CGI "
            "script, and HTTP status is not given through headers "
            "(value: %r)." % value)
        assert_('\n' not in name and ':' not in name,
            "Header names may not contain ':' or '\\n': %r" % name)
        assert_(header_re.search(name), "Bad header name: %r" % name)
        assert_(not name.endswith('-') and not name.endswith('_'),
            "Names may not end in '-' or '_': %r" % name)
        if bad_header_value_re.search(value):
            assert_(0, "Bad header value: %r (bad char: %r)"
            % (value, bad_header_value_re.search(value).group(0)))

def check_content_type(status, headers):
    status = check_string_type(status, "Status")
    code = int(status.split(None, 1)[0])
    # @@: need one more person to verify this interpretation of RFC 2616
    #     http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
    NO_MESSAGE_BODY = (204, 304)
    for name, value in headers:
        name = check_string_type(name, "Header name")
        if name.lower() == 'content-type':
            if code not in NO_MESSAGE_BODY:
                return
            assert_(0, ("Content-Type header found in a %s response, "
                        "which must not return content.") % code)
    if code not in NO_MESSAGE_BODY:
        assert_(0, "No Content-Type header found in headers (%s)" % headers)

def check_exc_info(exc_info):
    assert_(exc_info is None or type(exc_info) is tuple,
        "exc_info (%r) is not a tuple: %r" % (exc_info, type(exc_info)))
    # More exc_info checks?

def check_iterator(iterator):
    # Technically a bytestring is legal, which is why it's a really bad
    # idea, because it may cause the response to be returned
    # character-by-character
    assert_(not isinstance(iterator, (str, bytes)),
        "You should not return a string as your application iterator, "
        "instead return a single-item list containing a bytestring.")
headers.py000064400000015156150327210740006542 0ustar00"""Manage HTTP Response Headers

Much of this module is red-handedly pilfered from email.message in the stdlib,
so portions are Copyright (C) 2001,2002 Python Software Foundation, and were
written by Barry Warsaw.
"""

# Regular expression that matches `special' characters in parameters, the
# existence of which force quoting of the parameter value.
import re
tspecials = re.compile(r'[ \(\)<>@,;:\\"/\[\]\?=]')

def _formatparam(param, value=None, quote=1):
    """Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.
    """
    if value is not None and len(value) > 0:
        if quote or tspecials.search(value):
            value = value.replace('\\', '\\\\').replace('"', r'\"')
            return '%s="%s"' % (param, value)
        else:
            return '%s=%s' % (param, value)
    else:
        return param


class Headers:
    """Manage a collection of HTTP response headers"""

    def __init__(self, headers=None):
        headers = headers if headers is not None else []
        if type(headers) is not list:
            raise TypeError("Headers must be a list of name/value tuples")
        self._headers = headers
        if __debug__:
            for k, v in headers:
                self._convert_string_type(k)
                self._convert_string_type(v)

    def _convert_string_type(self, value):
        """Convert/check value type."""
        if type(value) is str:
            return value
        raise AssertionError("Header names/values must be"
            " of type str (got {0})".format(repr(value)))

    def __len__(self):
        """Return the total number of headers, including duplicates."""
        return len(self._headers)

    def __setitem__(self, name, val):
        """Set the value of a header."""
        del self[name]
        self._headers.append(
            (self._convert_string_type(name), self._convert_string_type(val)))

    def __delitem__(self,name):
        """Delete all occurrences of a header, if present.

        Does *not* raise an exception if the header is missing.
        """
        name = self._convert_string_type(name.lower())
        self._headers[:] = [kv for kv in self._headers if kv[0].lower() != name]

    def __getitem__(self,name):
        """Get the first header value for 'name'

        Return None if the header is missing instead of raising an exception.

        Note that if the header appeared multiple times, the first exactly which
        occurrence gets returned is undefined.  Use getall() to get all
        the values matching a header field name.
        """
        return self.get(name)

    def __contains__(self, name):
        """Return true if the message contains the header."""
        return self.get(name) is not None


    def get_all(self, name):
        """Return a list of all the values for the named field.

        These will be sorted in the order they appeared in the original header
        list or were added to this instance, and may contain duplicates.  Any
        fields deleted and re-inserted are always appended to the header list.
        If no fields exist with the given name, returns an empty list.
        """
        name = self._convert_string_type(name.lower())
        return [kv[1] for kv in self._headers if kv[0].lower()==name]


    def get(self,name,default=None):
        """Get the first header value for 'name', or return 'default'"""
        name = self._convert_string_type(name.lower())
        for k,v in self._headers:
            if k.lower()==name:
                return v
        return default


    def keys(self):
        """Return a list of all the header field names.

        These will be sorted in the order they appeared in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        """
        return [k for k, v in self._headers]

    def values(self):
        """Return a list of all header values.

        These will be sorted in the order they appeared in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        """
        return [v for k, v in self._headers]

    def items(self):
        """Get all the header fields and values.

        These will be sorted in the order they were in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        """
        return self._headers[:]

    def __repr__(self):
        return "%s(%r)" % (self.__class__.__name__, self._headers)

    def __str__(self):
        """str() returns the formatted headers, complete with end line,
        suitable for direct HTTP transmission."""
        return '\r\n'.join(["%s: %s" % kv for kv in self._headers]+['',''])

    def __bytes__(self):
        return str(self).encode('iso-8859-1')

    def setdefault(self,name,value):
        """Return first matching header value for 'name', or 'value'

        If there is no header named 'name', add a new header with name 'name'
        and value 'value'."""
        result = self.get(name)
        if result is None:
            self._headers.append((self._convert_string_type(name),
                self._convert_string_type(value)))
            return value
        else:
            return result

    def add_header(self, _name, _value, **_params):
        """Extended header setting.

        _name is the header field to add.  keyword arguments can be used to set
        additional parameters for the header field, with underscores converted
        to dashes.  Normally the parameter will be added as key="value" unless
        value is None, in which case only the key will be added.

        Example:

        h.add_header('content-disposition', 'attachment', filename='bud.gif')

        Note that unlike the corresponding 'email.message' method, this does
        *not* handle '(charset, language, value)' tuples: all values must be
        strings or None.
        """
        parts = []
        if _value is not None:
            _value = self._convert_string_type(_value)
            parts.append(_value)
        for k, v in _params.items():
            k = self._convert_string_type(k)
            if v is None:
                parts.append(k.replace('_', '-'))
            else:
                v = self._convert_string_type(v)
                parts.append(_formatparam(k.replace('_', '-'), v))
        self._headers.append((self._convert_string_type(_name), "; ".join(parts)))
validate.pyc000064400000040725150327210740007063 0ustar00�
{fc@sFdZdgZddlZddlZddlmZmZmZmZddl	Z	ej
d�Zej
d�Zde
fd��YZd	�Zd
�Zddd��YZd
dd��YZddd��YZdd d��YZdd!d��YZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS("s"
Middleware to check for obedience to the WSGI specification.

Some of the things this checks:

* Signature of the application and start_response (including that
  keyword arguments are not used).

* Environment checks:

  - Environment is a dictionary (and not a subclass).

  - That all the required keys are in the environment: REQUEST_METHOD,
    SERVER_NAME, SERVER_PORT, wsgi.version, wsgi.input, wsgi.errors,
    wsgi.multithread, wsgi.multiprocess, wsgi.run_once

  - That HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH are not in the
    environment (these headers should appear as CONTENT_LENGTH and
    CONTENT_TYPE).

  - Warns if QUERY_STRING is missing, as the cgi module acts
    unpredictably in that case.

  - That CGI-style variables (that don't contain a .) have
    (non-unicode) string values

  - That wsgi.version is a tuple

  - That wsgi.url_scheme is 'http' or 'https' (@@: is this too
    restrictive?)

  - Warns if the REQUEST_METHOD is not known (@@: probably too
    restrictive).

  - That SCRIPT_NAME and PATH_INFO are empty or start with /

  - That at least one of SCRIPT_NAME or PATH_INFO are set.

  - That CONTENT_LENGTH is a positive integer.

  - That SCRIPT_NAME is not '/' (it should be '', and PATH_INFO should
    be '/').

  - That wsgi.input has the methods read, readline, readlines, and
    __iter__

  - That wsgi.errors has the methods flush, write, writelines

* The status is a string, contains a space, starts with an integer,
  and that integer is in range (> 100).

* That the headers is a list (not a subclass, not another kind of
  sequence).

* That the items of the headers are tuples of strings.

* That there is no 'status' header (that is used in CGI, but not in
  WSGI).

* That the headers don't contain newlines or colons, end in _ or -, or
  contain characters codes below 037.

* That Content-Type is given if there is content (CGI often has a
  default content type, but WSGI does not).

* That no Content-Type is given when there is no content (@@: is this
  too restrictive?)

* That the exc_info argument to start_response is a tuple or None.

* That all calls to the writer are with strings, and no other methods
  on the writer are accessed.

* That wsgi.input is used properly:

  - .read() is called with zero or one argument

  - That it returns a string

  - That readline, readlines, and __iter__ return strings

  - That .close() is not called

  - No other methods are provided

* That wsgi.errors is used properly:

  - .write() and .writelines() is called with a string

  - That .close() is not called, and no other methods are provided.

* The response iterator:

  - That it is not a string (it should be a list of a single string; a
    string will work, but perform horribly).

  - That .next() returns a string

  - That the iterator is not iterated over until start_response has
    been called (that can signal either a server or application
    error).

  - That .close() is called (doesn't raise exception, only prints to
    sys.stderr, because we only know it isn't called when the object
    is garbage collected).
t	validatori����N(tDictTypet
StringTypet	TupleTypetListTypes^[a-zA-Z][a-zA-Z0-9\-_]*$s[\000-\037]tWSGIWarningcBseZdZRS(s:
    Raised in response to WSGI-spec-related warnings
    (t__name__t
__module__t__doc__(((s(/usr/lib64/python2.7/wsgiref/validate.pyRzscGs|st|��ndS(N(tAssertionError(tcondtargs((s(/usr/lib64/python2.7/wsgiref/validate.pytassert_scs�fd�}|S(s�
    When applied between a WSGI server and a WSGI application, this
    middleware will check for WSGI compliancy on a number of levels.
    This middleware does not modify the request or response in any
    way, but will raise an AssertionError if anything seems off
    (except for a failure to close the application iterator, which
    will be printed to stderr -- there's no way to raise an exception
    at that point).
    cs�tt|�dkd�t|d�|\}�t|�g���fd�}t|d�|d<t|d�|d<�||�}t|dk	o�|tkd�t|�t|��S(NisTwo arguments requiredsNo keyword arguments allowedcs�tt|�dkp$t|�dkd|f�t|d�|d}|d}t|�dkrs|d}nd}t|�t|�t||�t|��jd�t�|��S(NiisInvalid number of arguments: %ssNo keyword arguments allowedii(	RtlentNonetcheck_statust
check_headerstcheck_content_typetcheck_exc_infotappendtWriteWrapper(Rtkwtstatustheaderstexc_info(tstart_responsetstart_response_started(s(/usr/lib64/python2.7/wsgiref/validate.pytstart_response_wrapper�s$







s
wsgi.inputswsgi.errorss>The application must return an iterator, if only an empty list(	RR
t
check_environtInputWrappertErrorWrapperRtFalsetcheck_iteratortIteratorWrapper(RRtenvironRtiterator(tapplication(RRs(/usr/lib64/python2.7/wsgiref/validate.pytlint_app�s

((R$R%((R$s(/usr/lib64/python2.7/wsgiref/validate.pyR�s)RcBs>eZd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs
||_dS(N(tinput(tselft
wsgi_input((s(/usr/lib64/python2.7/wsgiref/validate.pyt__init__�scGsHtt|�dk�|jj|�}tt|�td�k�|S(Nit(RR
R&treadttype(R'Rtv((s(/usr/lib64/python2.7/wsgiref/validate.pyR+�scCs/|jj�}tt|�td�k�|S(NR*(R&treadlineRR,(R'R-((s(/usr/lib64/python2.7/wsgiref/validate.pyR.�scGsutt|�dk�|jj|�}tt|�tg�k�x*|D]"}tt|�td�k�qKW|S(NiR*(RR
R&t	readlinesR,(R'Rtlinestline((s(/usr/lib64/python2.7/wsgiref/validate.pyR/�s
 ccs&x|j�}|sdS|VqWdS(N(R.(R'R1((s(/usr/lib64/python2.7/wsgiref/validate.pyt__iter__�s
cCstdd�dS(Nis input.close() must not be called(R(R'((s(/usr/lib64/python2.7/wsgiref/validate.pytclose�s(RRR)R+R.R/R2R3(((s(/usr/lib64/python2.7/wsgiref/validate.pyR�s					RcBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCs
||_dS(N(terrors(R'twsgi_errors((s(/usr/lib64/python2.7/wsgiref/validate.pyR)�scCs0tt|�td�k�|jj|�dS(NR*(RR,R4twrite(R'ts((s(/usr/lib64/python2.7/wsgiref/validate.pyR6�scCs|jj�dS(N(R4tflush(R'((s(/usr/lib64/python2.7/wsgiref/validate.pyR8�scCs"x|D]}|j|�qWdS(N(R6(R'tseqR1((s(/usr/lib64/python2.7/wsgiref/validate.pyt
writelines�s
cCstdd�dS(Nis!errors.close() must not be called(R(R'((s(/usr/lib64/python2.7/wsgiref/validate.pyR3�s(RRR)R6R8R:R3(((s(/usr/lib64/python2.7/wsgiref/validate.pyR�s
				RcBseZd�Zd�ZRS(cCs
||_dS(N(twriter(R'twsgi_writer((s(/usr/lib64/python2.7/wsgiref/validate.pyR)�scCs-tt|�td�k�|j|�dS(NR*(RR,R;(R'R7((s(/usr/lib64/python2.7/wsgiref/validate.pyt__call__�s(RRR)R=(((s(/usr/lib64/python2.7/wsgiref/validate.pyR�s	tPartialIteratorWrappercBseZd�Zd�ZRS(cCs
||_dS(N(R#(R't
wsgi_iterator((s(/usr/lib64/python2.7/wsgiref/validate.pyR)�scCst|jd�S(N(R!R#R(R'((s(/usr/lib64/python2.7/wsgiref/validate.pyR2�s(RRR)R2(((s(/usr/lib64/python2.7/wsgiref/validate.pyR>�s	R!cBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCs.||_t|�|_t|_||_dS(N(toriginal_iteratortiterR#Rtclosedtcheck_start_response(R'R?RC((s(/usr/lib64/python2.7/wsgiref/validate.pyR)s		cCs|S(N((R'((s(/usr/lib64/python2.7/wsgiref/validate.pyR2	scCsOt|jd�|jj�}|jdk	rKt|jd�d|_n|S(NsIterator read after closedsjThe application returns and we started iterating over its body, but start_response has not yet been called(RRBR#tnextRCR(R'R-((s(/usr/lib64/python2.7/wsgiref/validate.pyRDs
	cCs/t|_t|jd�r+|jj�ndS(NR3(tTrueRBthasattrR@R3(R'((s(/usr/lib64/python2.7/wsgiref/validate.pyR3s	cCs0|jstjjd�nt|jd�dS(Ns/Iterator garbage collected without being closed(RBtsyststderrR6R(R'((s(/usr/lib64/python2.7/wsgiref/validate.pyt__del__s
		
	(RRR)R2RDR3RI(((s(/usr/lib64/python2.7/wsgiref/validate.pyR!s
			
	c	Cs�tt|�tkdt|�|f�xCdddddddd	d
g	D] }t||kd|f�qKWx5dd
gD]'}t||kd||df�q|Wd|kr�tjdt�nx^|j�D]P}d|kr�q�ntt||�tkd|t||�||f�q�Wtt|d�tkd|df�t|dd,kd|d�t	|d�t
|d�|dd-kr�tjd!|dt�nt|jd"�p�|d"jd#�d$|d"�t|jd%�p
|d%jd#�d&|d%�|jd'�rPtt
|d'�d(kd)|d'�n|jd"�sutd%|kd*�nt|jd"�d#kd+�dS(.Ns:Environment is not of the right type: %r (environment: %r)tREQUEST_METHODtSERVER_NAMEtSERVER_PORTswsgi.versions
wsgi.inputswsgi.errorsswsgi.multithreadswsgi.multiprocesss
wsgi.run_onces$Environment missing required key: %rtHTTP_CONTENT_TYPEtHTTP_CONTENT_LENGTHs8Environment should not have the key: %s (use %s instead)itQUERY_STRINGs�QUERY_STRING is not in the WSGI environment; the cgi module will use sys.argv when this variable is missing, so application errors are more likelyt.s9Environmental variable %s is not a string: %r (value: %r)s#wsgi.version should be a tuple (%r)swsgi.url_schemethttpthttpsswsgi.url_scheme unknown: %rtGETtHEADtPOSTtOPTIONStPATCHtPUTtDELETEtTRACEsUnknown REQUEST_METHOD: %rtSCRIPT_NAMEt/s$SCRIPT_NAME doesn't start with /: %rt	PATH_INFOs"PATH_INFO doesn't start with /: %rtCONTENT_LENGTHisInvalid CONTENT_LENGTH: %rsgOne of SCRIPT_NAME or PATH_INFO are required (PATH_INFO should at least be '/' if SCRIPT_NAME is empty)sOSCRIPT_NAME cannot be '/'; it should instead be '', and PATH_INFO should be '/'(RQRR(RSRTRURVRWRXRYRZ(RR,RtwarningstwarnRtkeysRRtcheck_inputtcheck_errorstgett
startswithtint(R"tkey((s(/usr/lib64/python2.7/wsgiref/validate.pyR"s`	

#	

cCsAx:ddddgD]&}tt||�d||f�qWdS(NR+R.R/R2s-wsgi.input (%r) doesn't have the attribute %s(RRF(R(tattr((s(/usr/lib64/python2.7/wsgiref/validate.pyRbcscCs>x7dddgD]&}tt||�d||f�qWdS(NR8R6R:s.wsgi.errors (%r) doesn't have the attribute %s(RRF(R5Rh((s(/usr/lib64/python2.7/wsgiref/validate.pyRciscCs�tt|�tkd|�|jdd�d}tt|�dkd|�t|�}t|dkd|�t|�dks�|dd	kr�tjd
|t	�ndS(Ns Status must be a string (not %r)iiis)Status codes must be three characters: %ridsStatus code is invalid: %rit sjThe status string (%r) should be a three-digit integer followed by a single space and a status explanation(
RR,RtsplitRR
RfR_R`R(Rtstatus_codet
status_int((s(/usr/lib64/python2.7/wsgiref/validate.pyRos"cCs_tt|�tkd|t|�f�i}x)|D]!}tt|�tkd|t|�f�tt|�dk�|\}}t|j�dkd|�d||j�<td|ko�d|kd|�ttj|�d	|�t|j	d
�o|j	d�d|�t
j|�r6td
d|t
j|�jd
�f�q6q6WdS(Ns%Headers (%r) must be of type list: %rs1Individual headers (%r) must be of type tuple: %riRsyThe Status header cannot be used; it conflicts with CGI script, and HTTP status is not given through headers (value: %r).s
t:s,Header names may not contain ':' or '\n': %rsBad header name: %rt-t_s#Names may not end in '-' or '_': %ris#Bad header value: %r (bad char: %r)(RR,RRR
tlowerRt	header_retsearchtendswithtbad_header_value_retgroup(Rtheader_namestitemtnametvalue((s(/usr/lib64/python2.7/wsgiref/validate.pyR~s,
 	cCs�t|jdd�d�}d}xJ|D]B\}}|j�dkr)||krWdStdd|�q)q)W||kr�tdd|�ndS(	Niii�i0scontent-typesJContent-Type header found in a %s response, which must not return content.s,No Content-Type header found in headers (%s)(i�i0(RfRjRRpR(RRtcodetNO_MESSAGE_BODYRxRy((s(/usr/lib64/python2.7/wsgiref/validate.pyR�s	cCs?t|dkp$t|�td�kd|t|�f�dS(Ns exc_info (%r) is not a tuple: %r((RRR,(R((s(/usr/lib64/python2.7/wsgiref/validate.pyR�s$cCstt|t�d�dS(NsvYou should not return a string as your application iterator, instead return a single-item list containing that string.(Rt
isinstancetstr(R#((s(/usr/lib64/python2.7/wsgiref/validate.pyR �s((((((Rt__all__treRGttypesRRRRR_tcompileRqRttWarningRRRRRRR>R!RRbRcRRRRR (((s(/usr/lib64/python2.7/wsgiref/validate.pyt<module>ns.	"		7"		!	A						util.pyo000064400000013551150327210740006260 0ustar00�
{fc@s�dZddlZddddddgZddd	��YZd
�Zd�Zdd
�Zd�Zd�Zidd6dd6dd6dd6dd6dd6dd6dd6j	Z
d�ZdS(s$Miscellaneous WSGI-related Utilitiesi����NtFileWrappertguess_schemetapplication_uritrequest_uritshift_path_infotsetup_testing_defaultscBs5eZdZdd�Zd�Zd�Zd�ZRS(s1Wrapper to convert file-like objects to iterablesi cCs4||_||_t|d�r0|j|_ndS(Ntclose(tfileliketblksizethasattrR(tselfRR((s$/usr/lib64/python2.7/wsgiref/util.pyt__init__s		cCs)|jj|j�}|r|St�dS(N(RtreadRt
IndexError(R
tkeytdata((s$/usr/lib64/python2.7/wsgiref/util.pyt__getitem__scCs|S(N((R
((s$/usr/lib64/python2.7/wsgiref/util.pyt__iter__scCs)|jj|j�}|r|St�dS(N(RRRt
StopIteration(R
R((s$/usr/lib64/python2.7/wsgiref/util.pytnexts(t__name__t
__module__t__doc__RRRR(((s$/usr/lib64/python2.7/wsgiref/util.pyRs
		cCs!|jd�dkrdSdSdS(	sMReturn a guess for whether 'wsgi.url_scheme' should be 'http' or 'https'
    tHTTPStyestont1thttpsthttpN(RRR(tget(tenviron((s$/usr/lib64/python2.7/wsgiref/util.pyR#scCs�|dd}ddlm}|jd�r>||d7}nk||d7}|ddkr�|dd	kr�|d
|d7}q�n%|ddkr�|d
|d7}n|||jd�p�d
�7}|S(s@Return the application's base URI (no PATH_INFO or QUERY_STRING)swsgi.url_schemes://i����(tquotet	HTTP_HOSTtSERVER_NAMERtSERVER_PORTt443t:t80tSCRIPT_NAMEt/(turllibRR(RturlR((s$/usr/lib64/python2.7/wsgiref/util.pyR+sicCs�t|�}ddlm}||jdd�dd�}|jd�sZ||d7}n
||7}|r�|jd	�r�|d
|d	7}n|S(sBReturn the full request URI, optionally including the query stringi����(Rt	PATH_INFOttsafes/;=,R&itQUERY_STRINGt?(RR(RR(Rt
include_queryR)Rt	path_info((s$/usr/lib64/python2.7/wsgiref/util.pyR?s
cCs|jdd�}|sdS|jd�}g|dd!D]}|r9|dkr9|^q9|dd+|d}|d=|jdd�}tj|d|�}|jd�r�|d }n|r�|jd�r�|d7}n||d<dj|�|d<|dkrd}n|S(	sZShift a name from PATH_INFO to SCRIPT_NAME, returning it

    If there are no remaining path segments in PATH_INFO, return None.
    Note: 'environ' is modified in-place; use a copy if you need to keep
    the original PATH_INFO or SCRIPT_NAME.

    Note: when PATH_INFO is just a '/', this returns '' and appends a trailing
    '/' to SCRIPT_NAME, even though empty path segments are normally ignored,
    and SCRIPT_NAME doesn't normally end in a '/'.  This is intentional
    behavior, to ensure that an application can tell the difference between
    '/x' and '/x/' when traversing to objects.
    R*R+R'ii����t.R&N(RtNonetsplitt	posixpathtnormpathtendswithtjoin(RR0t
path_partstptnametscript_name((s$/usr/lib64/python2.7/wsgiref/util.pyRLs$
9



	cCsX|jdd�|jdd�|jd|d�|jdd�d|krd	|kr|jdd
�|jd	d�n|jdd�|jdd�|jdd�|jdd�ddlm}|jd|d
��|jd|��|jdt|��|ddkr1|jdd�n#|ddkrT|jdd�ndS(s:Update 'environ' with trivial defaults for testing purposes

    This adds various parameters required for WSGI, including HTTP_HOST,
    SERVER_NAME, SERVER_PORT, REQUEST_METHOD, SCRIPT_NAME, PATH_INFO,
    and all of the wsgi.* variables.  It only supplies default values,
    and does not replace any existing settings for these variables.

    This routine is intended to make it easier for unit tests of WSGI
    servers and applications to set up dummy environments.  It should *not*
    be used by actual WSGI servers or applications, since the data is fake!
    R!s	127.0.0.1tSERVER_PROTOCOLsHTTP/1.0R tREQUEST_METHODtGETR&R*R+R'swsgi.versioniis
wsgi.run_onceswsgi.multithreadswsgi.multiprocessi����(tStringIOs
wsgi.inputswsgi.errorsswsgi.url_schemeRR"R%RR#N(ii(t
setdefaultR?R(RR?((s$/usr/lib64/python2.7/wsgiref/util.pyRus&
t
connections
keep-alivesproxy-authenticatesproxy-authorizationttettrailersstransfer-encodingtupgradecCst|j��S(s?Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header(t_hoppishtlower(theader_name((s$/usr/lib64/python2.7/wsgiref/util.pyt
is_hop_by_hop�s((RR4t__all__RRRRRRt__contains__RERH(((s$/usr/lib64/python2.7/wsgiref/util.pyt<module>s		
	)	(
handlers.pyc000064400000037576150327210740007104 0ustar00�
{fc
@sGdZddlmZddlmZmZmZddlmZddl	Z	ddl
Z
ddlZdddd	gZye
Wnek
r�d
�Z
nXddd
ddddgZeddddddddddddg
Zd�Zdfd��YZdefd ��YZdefd!��YZd	efd"��YZdS(#s/Base classes for server/gateway implementationsi����(t
StringType(tFileWrappertguess_schemet
is_hop_by_hop(tHeadersNtBaseHandlert
SimpleHandlertBaseCGIHandlert
CGIHandlercCs+i}x|D]\}}|||<q
W|S(N((titemstdtktv((s(/usr/lib64/python2.7/wsgiref/handlers.pytdictstMontTuetWedtThutFritSattSuntJantFebtMartAprtMaytJuntJultAugtSeptOcttNovtDecc
	CsOtj|�\	}}}}}}}}}	dt||t|||||fS(Ns#%s, %02d %3s %4d %02d:%02d:%02d GMT(ttimetgmtimet_weekdaynamet
_monthname(
t	timestamptyeartmonthtdaythhtmmtsstwdtytz((s(/usr/lib64/python2.7/wsgiref/handlers.pytformat_date_time#s*cBsbeZdZdZeZeZeZeZ	dZ
d Ze
ejj��ZeZeZd ZdZd!gZdZd ZZeZd ZdZd�Zd	�Z d
�Z!d�Z"d�Z#d
�Z$d d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d�Z/d�Z0d�Z1d�Z2d�Z3d�Z4d�Z5RS("s+Manage the invocation of a WSGI applicationiis1.0s500 Internal Server ErrorsContent-Types
text/plains;A server error occurred.  Please contact the administrator.cCscy0|j�||j|j�|_|j�Wn,y|j�Wq_|j��q_XnXdS(sInvoke the applicationN(t
setup_environtenvirontstart_responsetresulttfinish_responsethandle_errortclose(tselftapplication((s(/usr/lib64/python2.7/wsgiref/handlers.pytrunLs

cCs�|jj�}|_|j�|j�|d<|j�|d<|j|d<|j|d<|j�|d<|j	|d<|j
|d<|jd
k	r�|j|d<n|j
r�|jr�|jd	|j�nd
S(s&Set up the environment for one requests
wsgi.inputswsgi.errorsswsgi.versions
wsgi.run_onceswsgi.url_schemeswsgi.multithreadswsgi.multiprocessswsgi.file_wrappertSERVER_SOFTWAREN(t
os_environtcopyR1tadd_cgi_varst	get_stdint
get_stderrtwsgi_versiont
wsgi_run_oncet
get_schemetwsgi_multithreadtwsgi_multiprocesstwsgi_file_wrappertNonet
origin_servertserver_softwaret
setdefault(R7tenv((s(/usr/lib64/python2.7/wsgiref/handlers.pyR0`s




cCs^zL|j�s|j�rKx|jD]}|j|�q'W|j�nWd|j�XdS(s>Send any iterable data, then close self and the iterable

        Subclasses intended for use in asynchronous servers will
        want to redefine this method, such that it sets up callbacks
        in the event loop to iterate over the data, and to call
        'self.close()' once the response is finished.
        N(tresult_is_filetsendfileR3twritetfinish_contentR6(R7tdata((s(/usr/lib64/python2.7/wsgiref/handlers.pyR4uscCs
t|j�S(s Return the URL scheme being used(RR1(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyRB�scCsZyt|j�}Wntttfk
r/n'X|dkrVt|j�|jd<dSdS(s@Compute Content-Length or switch to chunked encoding if possibleisContent-LengthN(tlenR3t	TypeErrortAttributeErrortNotImplementedErrortstrt
bytes_senttheaders(R7tblocks((s(/usr/lib64/python2.7/wsgiref/handlers.pytset_content_length�scCs d|jkr|j�ndS(sqMake any necessary header changes or defaults

        Subclasses can extend this to add other defaults.
        sContent-LengthN(RVRX(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pytcleanup_headers�scCs[|r;z(|jr-|d|d|d�nWdd}Xn|jdk	rYtd��nt|�tkswtd��t|�dks�td��t|d	 �s�td
��|d	dks�td��xi|D]a\}}t|�tks�td
��t|�tkstd��t|�s�td��q�W||_	|j
|�|_|jS(s3'start_response()' callable as specified by PEP 333iiiNsHeaders already set!sStatus must be a stringis$Status must be at least 4 charactersis(Status message must begin w/3-digit codet s+Status message must have a space after codesHeader names must be stringssHeader values must be stringssHop-by-hop headers not allowed(theaders_sentRFRVtAssertionErrorttypeRRPtintRtstatust
headers_classRM(R7R_RVtexc_infotnametval((s(/usr/lib64/python2.7/wsgiref/handlers.pyR2�s$	
	cCs�|jr�|j�r�|jd|j|jf�d|jkra|jdttj���n|jr�d|jkr�|jd|j�q�q�n|jd|j�dS(s6Transmit version/status/date/server, via self._write()sHTTP/%s %s
tDates
Date: %s
tServersServer: %s
sStatus: %s
N(	RGtclient_is_modernt_writethttp_versionR_RVR/R!RH(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyt
send_preamble�s	cCs�t|�tkstd��|js6td��n:|js[t|�|_|j�n|jt|�7_|j|�|j	�dS(s*'write()' callable as specified by PEP 333swrite() argument must be stringswrite() before start_response()N(
R]RR\R_R[RPRUtsend_headersRgt_flush(R7RO((s(/usr/lib64/python2.7/wsgiref/handlers.pyRM�s		

cCstS(sPlatform-specific file transmission

        Override this method in subclasses to support platform-specific
        file transmission.  It is only called if the application's
        return iterable ('self.result') is an instance of
        'self.wsgi_file_wrapper'.

        This method should return a true value if it was able to actually
        transmit the wrapped file-like object using a platform-specific
        approach.  It should return a false value if normal iteration
        should be used instead.  An exception can be raised to indicate
        that transmission was attempted, but failed.

        NOTE: this method should call 'self.send_headers()' if
        'self.headers_sent' is false and it is going to attempt direct
        transmission of the file.
        (tFalse(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyRL�scCs-|js)|jjdd�|j�ndS(s.Ensure headers and content have both been sentsContent-Lengtht0N(R[RVRIRj(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyRN�s	
cCs^z&t|jd�r%|jj�nWdd|_|_|_|_d|_t|_	XdS(s�Close the iterable (if needed) and reset all instance vars

        Subclasses may want to also drop the client connection.
        R6Ni(
thasattrR3R6RFRVR_R1RURlR[(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR6�s	cCsP|j�t|_|js)|j�rL|j�|jt|j��ndS(s1Transmit headers to the client, via self._write()N(	RYtTrueR[RGRfRiRgRTRV(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyRj	s

	
cCs%|j}|dk	o$t|j|�S(s@True if 'self.result' is an instance of 'self.wsgi_file_wrapper'N(RERFt
isinstanceR3(R7twrapper((s(/usr/lib64/python2.7/wsgiref/handlers.pyRKs	cCs|jdj�dkS(s,True if client can accept status and headerstSERVER_PROTOCOLsHTTP/0.9(R1tupper(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyRfscCs]zOddlm}|j�}||d|d|d|j|�|j�Wdd}XdS(s�Log the 'exc_info' tuple in the server log

        Subclasses may override to retarget the output or change its format.
        i����(tprint_exceptioniiiN(t	tracebackRtR?ttraceback_limittflushRF(R7RaRttstderr((s(/usr/lib64/python2.7/wsgiref/handlers.pyt
log_exceptions
cCsH|jtj��|jsD|j|j|j�|_|j�ndS(s>Log current error, and send error output to client if possibleN(	RytsysRaR[terror_outputR1R2R3R4(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR5-s	cCs'||j|jtj��|jgS(sZWSGI mini-app to create error output

        By default, this just uses the 'error_status', 'error_headers',
        and 'error_body' attributes to generate an output page.  It can
        be overridden in a subclass to dynamically generate diagnostics,
        choose an appropriate message for the user's preferred language, etc.

        Note, however, that it's not recommended from a security perspective to
        spit out diagnostics to any old user; ideally, you should have to do
        something special to enable diagnostic output, which is why we don't
        include any here!
        (terror_statust
error_headersRzRat
error_body(R7R1R2((s(/usr/lib64/python2.7/wsgiref/handlers.pyR{5s
cCs
t�dS(sOverride in subclass to buffer data for send to client

        It's okay if this method actually transmits the data; BaseHandler
        just separates write and flush operations for greater efficiency
        when the underlying system actually has such a distinction.
        N(RS(R7RO((s(/usr/lib64/python2.7/wsgiref/handlers.pyRgHscCs
t�dS(s�Override in subclass to force sending of recent '_write()' calls

        It's okay if this method is a no-op (i.e., if '_write()' actually
        sends the data.
        N(RS(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyRkQscCs
t�dS(s4Override in subclass to return suitable 'wsgi.input'N(RS(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR>YscCs
t�dS(s5Override in subclass to return suitable 'wsgi.errors'N(RS(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR?]scCs
t�dS(s>Override in subclass to insert CGI variables in 'self.environ'N(RS(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR=as(iiN(sContent-Types
text/plain(6t__name__t
__module__t__doc__R@RoRCRDRlRARGRhRFRHR
tosR1R	R;RRERR`RvR|R}R~R_R3R[RVRUR9R0R4RBRXRYR2RiRMRLRNR6RjRKRfRyR5R{RgRkR>R?R=(((s(/usr/lib64/python2.7/wsgiref/handlers.pyR*sT	
					
					
	
												cBsJeZdZeed�Zd�Zd�Zd�Zd�Z	d�Z
RS(sqHandler that's just initialized with streams, environment, etc.

    This handler subclass is intended for synchronous HTTP/1.0 origin servers,
    and handles sending the entire response output, given the correct inputs.

    Usage::

        handler = SimpleHandler(
            inp,out,err,env, multithread=False, multiprocess=True
        )
        handler.run(app)cCs:||_||_||_||_||_||_dS(N(tstdintstdoutRxtbase_envRCRD(R7R�R�RxR1tmultithreadtmultiprocess((s(/usr/lib64/python2.7/wsgiref/handlers.pyt__init__ss					cCs|jS(N(R�(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR>}scCs|jS(N(Rx(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR?�scCs|jj|j�dS(N(R1tupdateR�(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR=�scCs#|jj|�|jj|_dS(N(R�RMRg(R7RO((s(/usr/lib64/python2.7/wsgiref/handlers.pyRg�scCs |jj�|jj|_dS(N(R�RwRk(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyRk�s
(RR�R�RoRlR�R>R?R=RgRk(((s(/usr/lib64/python2.7/wsgiref/handlers.pyRfs					cBseZdZeZRS(s�CGI-like systems using input/output/error streams and environ mapping

    Usage::

        handler = BaseCGIHandler(inp,out,err,env)
        handler.run(app)

    This handler class is useful for gateway protocols like ReadyExec and
    FastCGI, that have usable input/output/error streams and an environment
    mapping.  It's also the base class for CGIHandler, which just uses
    sys.stdin, os.environ, and so on.

    The constructor also takes keyword arguments 'multithread' and
    'multiprocess' (defaulting to 'True' and 'False' respectively) to control
    the configuration sent to the application.  It sets 'origin_server' to
    False (to enable CGI-like output), and assumes that 'wsgi.run_once' is
    False.
    (RR�R�RlRG(((s(/usr/lib64/python2.7/wsgiref/handlers.pyR�scBs#eZdZeZiZd�ZRS(s�CGI-based invocation via sys.stdin/stdout/stderr and os.environ

    Usage::

        CGIHandler().run(app)

    The difference between this class and BaseCGIHandler is that it always
    uses 'wsgi.run_once' of 'True', 'wsgi.multithread' of 'False', and
    'wsgi.multiprocess' of 'True'.  It does not take any initialization
    parameters, but always uses 'sys.stdin', 'os.environ', and friends.

    If you need to override any of these parameters, use BaseCGIHandler
    instead.
    c
CsAtj|tjtjtjttjj	��dt
dt�dS(NR�R�(RR�RzR�R�RxR
R�R1R	RlRo(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR��s*(RR�R�RoRAR;R�(((s(/usr/lib64/python2.7/wsgiref/handlers.pyR�s(R�ttypesRtutilRRRRVRRzR�R!t__all__R
t	NameErrorR#RFR$R/RRRR(((s(/usr/lib64/python2.7/wsgiref/handlers.pyt<module>s&$

	�=)util.pyc000064400000013551150327210740006244 0ustar00�
{fc@s�dZddlZddddddgZddd	��YZd
�Zd�Zdd
�Zd�Zd�Zidd6dd6dd6dd6dd6dd6dd6dd6j	Z
d�ZdS(s$Miscellaneous WSGI-related Utilitiesi����NtFileWrappertguess_schemetapplication_uritrequest_uritshift_path_infotsetup_testing_defaultscBs5eZdZdd�Zd�Zd�Zd�ZRS(s1Wrapper to convert file-like objects to iterablesi cCs4||_||_t|d�r0|j|_ndS(Ntclose(tfileliketblksizethasattrR(tselfRR((s$/usr/lib64/python2.7/wsgiref/util.pyt__init__s		cCs)|jj|j�}|r|St�dS(N(RtreadRt
IndexError(R
tkeytdata((s$/usr/lib64/python2.7/wsgiref/util.pyt__getitem__scCs|S(N((R
((s$/usr/lib64/python2.7/wsgiref/util.pyt__iter__scCs)|jj|j�}|r|St�dS(N(RRRt
StopIteration(R
R((s$/usr/lib64/python2.7/wsgiref/util.pytnexts(t__name__t
__module__t__doc__RRRR(((s$/usr/lib64/python2.7/wsgiref/util.pyRs
		cCs!|jd�dkrdSdSdS(	sMReturn a guess for whether 'wsgi.url_scheme' should be 'http' or 'https'
    tHTTPStyestont1thttpsthttpN(RRR(tget(tenviron((s$/usr/lib64/python2.7/wsgiref/util.pyR#scCs�|dd}ddlm}|jd�r>||d7}nk||d7}|ddkr�|dd	kr�|d
|d7}q�n%|ddkr�|d
|d7}n|||jd�p�d
�7}|S(s@Return the application's base URI (no PATH_INFO or QUERY_STRING)swsgi.url_schemes://i����(tquotet	HTTP_HOSTtSERVER_NAMERtSERVER_PORTt443t:t80tSCRIPT_NAMEt/(turllibRR(RturlR((s$/usr/lib64/python2.7/wsgiref/util.pyR+sicCs�t|�}ddlm}||jdd�dd�}|jd�sZ||d7}n
||7}|r�|jd	�r�|d
|d	7}n|S(sBReturn the full request URI, optionally including the query stringi����(Rt	PATH_INFOttsafes/;=,R&itQUERY_STRINGt?(RR(RR(Rt
include_queryR)Rt	path_info((s$/usr/lib64/python2.7/wsgiref/util.pyR?s
cCs|jdd�}|sdS|jd�}g|dd!D]}|r9|dkr9|^q9|dd+|d}|d=|jdd�}tj|d|�}|jd�r�|d }n|r�|jd�r�|d7}n||d<dj|�|d<|dkrd}n|S(	sZShift a name from PATH_INFO to SCRIPT_NAME, returning it

    If there are no remaining path segments in PATH_INFO, return None.
    Note: 'environ' is modified in-place; use a copy if you need to keep
    the original PATH_INFO or SCRIPT_NAME.

    Note: when PATH_INFO is just a '/', this returns '' and appends a trailing
    '/' to SCRIPT_NAME, even though empty path segments are normally ignored,
    and SCRIPT_NAME doesn't normally end in a '/'.  This is intentional
    behavior, to ensure that an application can tell the difference between
    '/x' and '/x/' when traversing to objects.
    R*R+R'ii����t.R&N(RtNonetsplitt	posixpathtnormpathtendswithtjoin(RR0t
path_partstptnametscript_name((s$/usr/lib64/python2.7/wsgiref/util.pyRLs$
9



	cCsX|jdd�|jdd�|jd|d�|jdd�d|krd	|kr|jdd
�|jd	d�n|jdd�|jdd�|jdd�|jdd�ddlm}|jd|d
��|jd|��|jdt|��|ddkr1|jdd�n#|ddkrT|jdd�ndS(s:Update 'environ' with trivial defaults for testing purposes

    This adds various parameters required for WSGI, including HTTP_HOST,
    SERVER_NAME, SERVER_PORT, REQUEST_METHOD, SCRIPT_NAME, PATH_INFO,
    and all of the wsgi.* variables.  It only supplies default values,
    and does not replace any existing settings for these variables.

    This routine is intended to make it easier for unit tests of WSGI
    servers and applications to set up dummy environments.  It should *not*
    be used by actual WSGI servers or applications, since the data is fake!
    R!s	127.0.0.1tSERVER_PROTOCOLsHTTP/1.0R tREQUEST_METHODtGETR&R*R+R'swsgi.versioniis
wsgi.run_onceswsgi.multithreadswsgi.multiprocessi����(tStringIOs
wsgi.inputswsgi.errorsswsgi.url_schemeRR"R%RR#N(ii(t
setdefaultR?R(RR?((s$/usr/lib64/python2.7/wsgiref/util.pyRus&
t
connections
keep-alivesproxy-authenticatesproxy-authorizationttettrailersstransfer-encodingtupgradecCst|j��S(s?Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header(t_hoppishtlower(theader_name((s$/usr/lib64/python2.7/wsgiref/util.pyt
is_hop_by_hop�s((RR4t__all__RRRRRRt__contains__RERH(((s$/usr/lib64/python2.7/wsgiref/util.pyt<module>s		
	)	(
headers.pyo000064400000016461150327210740006721 0ustar00�
{fc@s]dZddlmZmZddlZejd�Zddd�Zdd	d��YZ	dS(
s�Manage HTTP Response Headers

Much of this module is red-handedly pilfered from email.message in the stdlib,
so portions are Copyright (C) 2001,2002 Python Software Foundation, and were
written by Barry Warsaw.
i����(tListTypet	TupleTypeNs[ \(\)<>@,;:\\"/\[\]\?=]icCsx|dk	rpt|�dkrp|s3tj|�r_|jdd�jdd�}d||fSd||fSn|SdS(	s~Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.
    is\s\\t"s\"s%s="%s"s%s=%sN(tNonetlent	tspecialstsearchtreplace(tparamtvaluetquote((s'/usr/lib64/python2.7/wsgiref/headers.pyt_formatparamstHeaderscBs�eZdZd�Zd�Zd�Zd�Zd�Zd�ZeZ	d�Z
dd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�ZRS(s,Manage a collection of HTTP response headerscCs.t|�tk	r!td��n||_dS(Ns+Headers must be a list of name/value tuples(ttypeRt	TypeErrort_headers(tselftheaders((s'/usr/lib64/python2.7/wsgiref/headers.pyt__init__"scCs
t|j�S(s9Return the total number of headers, including duplicates.(RR(R((s'/usr/lib64/python2.7/wsgiref/headers.pyt__len__'scCs!||=|jj||f�dS(sSet the value of a header.N(Rtappend(Rtnametval((s'/usr/lib64/python2.7/wsgiref/headers.pyt__setitem__+scCsF|j�}g|jD]"}|dj�|kr|^q|j(dS(syDelete all occurrences of a header, if present.

        Does *not* raise an exception if the header is missing.
        iN(tlowerR(RRtkv((s'/usr/lib64/python2.7/wsgiref/headers.pyt__delitem__0scCs
|j|�S(sHGet the first header value for 'name'

        Return None if the header is missing instead of raising an exception.

        Note that if the header appeared multiple times, the first exactly which
        occurrence gets returned is undefined.  Use getall() to get all
        the values matching a header field name.
        (tget(RR((s'/usr/lib64/python2.7/wsgiref/headers.pyt__getitem__8s	cCs|j|�dk	S(s/Return true if the message contains the header.N(RR(RR((s'/usr/lib64/python2.7/wsgiref/headers.pythas_keyCscCs@|j�}g|jD]&}|dj�|kr|d^qS(sqReturn a list of all the values for the named field.

        These will be sorted in the order they appeared in the original header
        list or were added to this instance, and may contain duplicates.  Any
        fields deleted and re-inserted are always appended to the header list.
        If no fields exist with the given name, returns an empty list.
        ii(RR(RRR((s'/usr/lib64/python2.7/wsgiref/headers.pytget_allJscCs@|j�}x-|jD]"\}}|j�|kr|SqW|S(s:Get the first header value for 'name', or return 'default'(RR(RRtdefaulttktv((s'/usr/lib64/python2.7/wsgiref/headers.pyRVs
cCs g|jD]\}}|^q
S(s*Return a list of all the header field names.

        These will be sorted in the order they appeared in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        (R(RR R!((s'/usr/lib64/python2.7/wsgiref/headers.pytkeys_scCs g|jD]\}}|^q
S(s!Return a list of all header values.

        These will be sorted in the order they appeared in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        (R(RR R!((s'/usr/lib64/python2.7/wsgiref/headers.pytvaluesiscCs|jS(sGet all the header fields and values.

        These will be sorted in the order they were in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        (R(R((s'/usr/lib64/python2.7/wsgiref/headers.pytitemssscCsd|jS(NsHeaders(%r)(R(R((s'/usr/lib64/python2.7/wsgiref/headers.pyt__repr__}scCs1djg|jD]}d|^qddg�S(skstr() returns the formatted headers, complete with end line,
        suitable for direct HTTP transmission.s
s%s: %st(tjoinR(RR((s'/usr/lib64/python2.7/wsgiref/headers.pyt__str__�scCs=|j|�}|dkr5|jj||f�|S|SdS(s�Return first matching header value for 'name', or 'value'

        If there is no header named 'name', add a new header with name 'name'
        and value 'value'.N(RRRR(RRR	tresult((s'/usr/lib64/python2.7/wsgiref/headers.pyt
setdefault�s
cKs�g}|dk	r"|j|�nxd|j�D]V\}}|dkrc|j|jdd��q/|jt|jdd�|��q/W|jj|dj|�f�dS(sfExtended header setting.

        _name is the header field to add.  keyword arguments can be used to set
        additional parameters for the header field, with underscores converted
        to dashes.  Normally the parameter will be added as key="value" unless
        value is None, in which case only the key will be added.

        Example:

        h.add_header('content-disposition', 'attachment', filename='bud.gif')

        Note that unlike the corresponding 'email.message' method, this does
        *not* handle '(charset, language, value)' tuples: all values must be
        strings or None.
        t_t-s; N(RRR$RRRR'(Rt_namet_valuet_paramstpartsR R!((s'/usr/lib64/python2.7/wsgiref/headers.pyt
add_header�s&N(t__name__t
__module__t__doc__RRRRRRt__contains__RRRR"R#R$R%R(R*R1(((s'/usr/lib64/python2.7/wsgiref/headers.pyRs"									
	
	
			((
R4ttypesRRtretcompileRRRR(((s'/usr/lib64/python2.7/wsgiref/headers.pyt<module>s
headers.pyc000064400000016461150327210740006705 0ustar00�
{fc@s]dZddlmZmZddlZejd�Zddd�Zdd	d��YZ	dS(
s�Manage HTTP Response Headers

Much of this module is red-handedly pilfered from email.message in the stdlib,
so portions are Copyright (C) 2001,2002 Python Software Foundation, and were
written by Barry Warsaw.
i����(tListTypet	TupleTypeNs[ \(\)<>@,;:\\"/\[\]\?=]icCsx|dk	rpt|�dkrp|s3tj|�r_|jdd�jdd�}d||fSd||fSn|SdS(	s~Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.
    is\s\\t"s\"s%s="%s"s%s=%sN(tNonetlent	tspecialstsearchtreplace(tparamtvaluetquote((s'/usr/lib64/python2.7/wsgiref/headers.pyt_formatparamstHeaderscBs�eZdZd�Zd�Zd�Zd�Zd�Zd�ZeZ	d�Z
dd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�ZRS(s,Manage a collection of HTTP response headerscCs.t|�tk	r!td��n||_dS(Ns+Headers must be a list of name/value tuples(ttypeRt	TypeErrort_headers(tselftheaders((s'/usr/lib64/python2.7/wsgiref/headers.pyt__init__"scCs
t|j�S(s9Return the total number of headers, including duplicates.(RR(R((s'/usr/lib64/python2.7/wsgiref/headers.pyt__len__'scCs!||=|jj||f�dS(sSet the value of a header.N(Rtappend(Rtnametval((s'/usr/lib64/python2.7/wsgiref/headers.pyt__setitem__+scCsF|j�}g|jD]"}|dj�|kr|^q|j(dS(syDelete all occurrences of a header, if present.

        Does *not* raise an exception if the header is missing.
        iN(tlowerR(RRtkv((s'/usr/lib64/python2.7/wsgiref/headers.pyt__delitem__0scCs
|j|�S(sHGet the first header value for 'name'

        Return None if the header is missing instead of raising an exception.

        Note that if the header appeared multiple times, the first exactly which
        occurrence gets returned is undefined.  Use getall() to get all
        the values matching a header field name.
        (tget(RR((s'/usr/lib64/python2.7/wsgiref/headers.pyt__getitem__8s	cCs|j|�dk	S(s/Return true if the message contains the header.N(RR(RR((s'/usr/lib64/python2.7/wsgiref/headers.pythas_keyCscCs@|j�}g|jD]&}|dj�|kr|d^qS(sqReturn a list of all the values for the named field.

        These will be sorted in the order they appeared in the original header
        list or were added to this instance, and may contain duplicates.  Any
        fields deleted and re-inserted are always appended to the header list.
        If no fields exist with the given name, returns an empty list.
        ii(RR(RRR((s'/usr/lib64/python2.7/wsgiref/headers.pytget_allJscCs@|j�}x-|jD]"\}}|j�|kr|SqW|S(s:Get the first header value for 'name', or return 'default'(RR(RRtdefaulttktv((s'/usr/lib64/python2.7/wsgiref/headers.pyRVs
cCs g|jD]\}}|^q
S(s*Return a list of all the header field names.

        These will be sorted in the order they appeared in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        (R(RR R!((s'/usr/lib64/python2.7/wsgiref/headers.pytkeys_scCs g|jD]\}}|^q
S(s!Return a list of all header values.

        These will be sorted in the order they appeared in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        (R(RR R!((s'/usr/lib64/python2.7/wsgiref/headers.pytvaluesiscCs|jS(sGet all the header fields and values.

        These will be sorted in the order they were in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        (R(R((s'/usr/lib64/python2.7/wsgiref/headers.pytitemssscCsd|jS(NsHeaders(%r)(R(R((s'/usr/lib64/python2.7/wsgiref/headers.pyt__repr__}scCs1djg|jD]}d|^qddg�S(skstr() returns the formatted headers, complete with end line,
        suitable for direct HTTP transmission.s
s%s: %st(tjoinR(RR((s'/usr/lib64/python2.7/wsgiref/headers.pyt__str__�scCs=|j|�}|dkr5|jj||f�|S|SdS(s�Return first matching header value for 'name', or 'value'

        If there is no header named 'name', add a new header with name 'name'
        and value 'value'.N(RRRR(RRR	tresult((s'/usr/lib64/python2.7/wsgiref/headers.pyt
setdefault�s
cKs�g}|dk	r"|j|�nxd|j�D]V\}}|dkrc|j|jdd��q/|jt|jdd�|��q/W|jj|dj|�f�dS(sfExtended header setting.

        _name is the header field to add.  keyword arguments can be used to set
        additional parameters for the header field, with underscores converted
        to dashes.  Normally the parameter will be added as key="value" unless
        value is None, in which case only the key will be added.

        Example:

        h.add_header('content-disposition', 'attachment', filename='bud.gif')

        Note that unlike the corresponding 'email.message' method, this does
        *not* handle '(charset, language, value)' tuples: all values must be
        strings or None.
        t_t-s; N(RRR$RRRR'(Rt_namet_valuet_paramstpartsR R!((s'/usr/lib64/python2.7/wsgiref/headers.pyt
add_header�s&N(t__name__t
__module__t__doc__RRRRRRt__contains__RRRR"R#R$R%R(R*R1(((s'/usr/lib64/python2.7/wsgiref/headers.pyRs"									
	
	
			((
R4ttypesRRtretcompileRRRR(((s'/usr/lib64/python2.7/wsgiref/headers.pyt<module>s
handlers.pyo000064400000036367150327210740007115 0ustar00�
{fc
@sGdZddlmZddlmZmZmZddlmZddl	Z	ddl
Z
ddlZdddd	gZye
Wnek
r�d
�Z
nXddd
ddddgZeddddddddddddg
Zd�Zdfd��YZdefd ��YZdefd!��YZd	efd"��YZdS(#s/Base classes for server/gateway implementationsi����(t
StringType(tFileWrappertguess_schemet
is_hop_by_hop(tHeadersNtBaseHandlert
SimpleHandlertBaseCGIHandlert
CGIHandlercCs+i}x|D]\}}|||<q
W|S(N((titemstdtktv((s(/usr/lib64/python2.7/wsgiref/handlers.pytdictstMontTuetWedtThutFritSattSuntJantFebtMartAprtMaytJuntJultAugtSeptOcttNovtDecc
	CsOtj|�\	}}}}}}}}}	dt||t|||||fS(Ns#%s, %02d %3s %4d %02d:%02d:%02d GMT(ttimetgmtimet_weekdaynamet
_monthname(
t	timestamptyeartmonthtdaythhtmmtsstwdtytz((s(/usr/lib64/python2.7/wsgiref/handlers.pytformat_date_time#s*cBsbeZdZdZeZeZeZeZ	dZ
d Ze
ejj��ZeZeZd ZdZd!gZdZd ZZeZd ZdZd�Zd	�Z d
�Z!d�Z"d�Z#d
�Z$d d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d�Z/d�Z0d�Z1d�Z2d�Z3d�Z4d�Z5RS("s+Manage the invocation of a WSGI applicationiis1.0s500 Internal Server ErrorsContent-Types
text/plains;A server error occurred.  Please contact the administrator.cCscy0|j�||j|j�|_|j�Wn,y|j�Wq_|j��q_XnXdS(sInvoke the applicationN(t
setup_environtenvirontstart_responsetresulttfinish_responsethandle_errortclose(tselftapplication((s(/usr/lib64/python2.7/wsgiref/handlers.pytrunLs

cCs�|jj�}|_|j�|j�|d<|j�|d<|j|d<|j|d<|j�|d<|j	|d<|j
|d<|jd
k	r�|j|d<n|j
r�|jr�|jd	|j�nd
S(s&Set up the environment for one requests
wsgi.inputswsgi.errorsswsgi.versions
wsgi.run_onceswsgi.url_schemeswsgi.multithreadswsgi.multiprocessswsgi.file_wrappertSERVER_SOFTWAREN(t
os_environtcopyR1tadd_cgi_varst	get_stdint
get_stderrtwsgi_versiont
wsgi_run_oncet
get_schemetwsgi_multithreadtwsgi_multiprocesstwsgi_file_wrappertNonet
origin_servertserver_softwaret
setdefault(R7tenv((s(/usr/lib64/python2.7/wsgiref/handlers.pyR0`s




cCs^zL|j�s|j�rKx|jD]}|j|�q'W|j�nWd|j�XdS(s>Send any iterable data, then close self and the iterable

        Subclasses intended for use in asynchronous servers will
        want to redefine this method, such that it sets up callbacks
        in the event loop to iterate over the data, and to call
        'self.close()' once the response is finished.
        N(tresult_is_filetsendfileR3twritetfinish_contentR6(R7tdata((s(/usr/lib64/python2.7/wsgiref/handlers.pyR4uscCs
t|j�S(s Return the URL scheme being used(RR1(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyRB�scCsZyt|j�}Wntttfk
r/n'X|dkrVt|j�|jd<dSdS(s@Compute Content-Length or switch to chunked encoding if possibleisContent-LengthN(tlenR3t	TypeErrortAttributeErrortNotImplementedErrortstrt
bytes_senttheaders(R7tblocks((s(/usr/lib64/python2.7/wsgiref/handlers.pytset_content_length�scCs d|jkr|j�ndS(sqMake any necessary header changes or defaults

        Subclasses can extend this to add other defaults.
        sContent-LengthN(RVRX(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pytcleanup_headers�scCs{|r;z(|jr-|d|d|d�nWdd}Xn|jdk	rYtd��n||_|j|�|_|jS(s3'start_response()' callable as specified by PEP 333iiiNsHeaders already set!(theaders_sentRFRVtAssertionErrortstatust
headers_classRM(R7R\RVtexc_info((s(/usr/lib64/python2.7/wsgiref/handlers.pyR2�s	
	cCs�|jr�|j�r�|jd|j|jf�d|jkra|jdttj���n|jr�d|jkr�|jd|j�q�q�n|jd|j�dS(s6Transmit version/status/date/server, via self._write()sHTTP/%s %s
tDates
Date: %s
tServersServer: %s
sStatus: %s
N(	RGtclient_is_modernt_writethttp_versionR\RVR/R!RH(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyt
send_preamble�s	cCsm|jstd��n:|js=t|�|_|j�n|jt|�7_|j|�|j�dS(s*'write()' callable as specified by PEP 333swrite() before start_response()N(R\R[RZRPRUtsend_headersRbt_flush(R7RO((s(/usr/lib64/python2.7/wsgiref/handlers.pyRM�s		

cCstS(sPlatform-specific file transmission

        Override this method in subclasses to support platform-specific
        file transmission.  It is only called if the application's
        return iterable ('self.result') is an instance of
        'self.wsgi_file_wrapper'.

        This method should return a true value if it was able to actually
        transmit the wrapped file-like object using a platform-specific
        approach.  It should return a false value if normal iteration
        should be used instead.  An exception can be raised to indicate
        that transmission was attempted, but failed.

        NOTE: this method should call 'self.send_headers()' if
        'self.headers_sent' is false and it is going to attempt direct
        transmission of the file.
        (tFalse(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyRL�scCs-|js)|jjdd�|j�ndS(s.Ensure headers and content have both been sentsContent-Lengtht0N(RZRVRIRe(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyRN�s	
cCs^z&t|jd�r%|jj�nWdd|_|_|_|_d|_t|_	XdS(s�Close the iterable (if needed) and reset all instance vars

        Subclasses may want to also drop the client connection.
        R6Ni(
thasattrR3R6RFRVR\R1RURgRZ(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR6�s	cCsP|j�t|_|js)|j�rL|j�|jt|j��ndS(s1Transmit headers to the client, via self._write()N(	RYtTrueRZRGRaRdRbRTRV(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyRe	s

	
cCs%|j}|dk	o$t|j|�S(s@True if 'self.result' is an instance of 'self.wsgi_file_wrapper'N(RERFt
isinstanceR3(R7twrapper((s(/usr/lib64/python2.7/wsgiref/handlers.pyRKs	cCs|jdj�dkS(s,True if client can accept status and headerstSERVER_PROTOCOLsHTTP/0.9(R1tupper(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyRascCs]zOddlm}|j�}||d|d|d|j|�|j�Wdd}XdS(s�Log the 'exc_info' tuple in the server log

        Subclasses may override to retarget the output or change its format.
        i����(tprint_exceptioniiiN(t	tracebackRoR?ttraceback_limittflushRF(R7R^Rotstderr((s(/usr/lib64/python2.7/wsgiref/handlers.pyt
log_exceptions
cCsH|jtj��|jsD|j|j|j�|_|j�ndS(s>Log current error, and send error output to client if possibleN(	RttsysR^RZterror_outputR1R2R3R4(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR5-s	cCs'||j|jtj��|jgS(sZWSGI mini-app to create error output

        By default, this just uses the 'error_status', 'error_headers',
        and 'error_body' attributes to generate an output page.  It can
        be overridden in a subclass to dynamically generate diagnostics,
        choose an appropriate message for the user's preferred language, etc.

        Note, however, that it's not recommended from a security perspective to
        spit out diagnostics to any old user; ideally, you should have to do
        something special to enable diagnostic output, which is why we don't
        include any here!
        (terror_statust
error_headersRuR^t
error_body(R7R1R2((s(/usr/lib64/python2.7/wsgiref/handlers.pyRv5s
cCs
t�dS(sOverride in subclass to buffer data for send to client

        It's okay if this method actually transmits the data; BaseHandler
        just separates write and flush operations for greater efficiency
        when the underlying system actually has such a distinction.
        N(RS(R7RO((s(/usr/lib64/python2.7/wsgiref/handlers.pyRbHscCs
t�dS(s�Override in subclass to force sending of recent '_write()' calls

        It's okay if this method is a no-op (i.e., if '_write()' actually
        sends the data.
        N(RS(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyRfQscCs
t�dS(s4Override in subclass to return suitable 'wsgi.input'N(RS(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR>YscCs
t�dS(s5Override in subclass to return suitable 'wsgi.errors'N(RS(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR?]scCs
t�dS(s>Override in subclass to insert CGI variables in 'self.environ'N(RS(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR=as(iiN(sContent-Types
text/plain(6t__name__t
__module__t__doc__R@RjRCRDRgRARGRcRFRHR
tosR1R	R;RRERR]RqRwRxRyR\R3RZRVRUR9R0R4RBRXRYR2RdRMRLRNR6ReRKRaRtR5RvRbRfR>R?R=(((s(/usr/lib64/python2.7/wsgiref/handlers.pyR*sT	
					
					
	
												cBsJeZdZeed�Zd�Zd�Zd�Zd�Z	d�Z
RS(sqHandler that's just initialized with streams, environment, etc.

    This handler subclass is intended for synchronous HTTP/1.0 origin servers,
    and handles sending the entire response output, given the correct inputs.

    Usage::

        handler = SimpleHandler(
            inp,out,err,env, multithread=False, multiprocess=True
        )
        handler.run(app)cCs:||_||_||_||_||_||_dS(N(tstdintstdoutRstbase_envRCRD(R7R~RRsR1tmultithreadtmultiprocess((s(/usr/lib64/python2.7/wsgiref/handlers.pyt__init__ss					cCs|jS(N(R~(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR>}scCs|jS(N(Rs(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR?�scCs|jj|j�dS(N(R1tupdateR�(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR=�scCs#|jj|�|jj|_dS(N(RRMRb(R7RO((s(/usr/lib64/python2.7/wsgiref/handlers.pyRb�scCs |jj�|jj|_dS(N(RRrRf(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyRf�s
(RzR{R|RjRgR�R>R?R=RbRf(((s(/usr/lib64/python2.7/wsgiref/handlers.pyRfs					cBseZdZeZRS(s�CGI-like systems using input/output/error streams and environ mapping

    Usage::

        handler = BaseCGIHandler(inp,out,err,env)
        handler.run(app)

    This handler class is useful for gateway protocols like ReadyExec and
    FastCGI, that have usable input/output/error streams and an environment
    mapping.  It's also the base class for CGIHandler, which just uses
    sys.stdin, os.environ, and so on.

    The constructor also takes keyword arguments 'multithread' and
    'multiprocess' (defaulting to 'True' and 'False' respectively) to control
    the configuration sent to the application.  It sets 'origin_server' to
    False (to enable CGI-like output), and assumes that 'wsgi.run_once' is
    False.
    (RzR{R|RgRG(((s(/usr/lib64/python2.7/wsgiref/handlers.pyR�scBs#eZdZeZiZd�ZRS(s�CGI-based invocation via sys.stdin/stdout/stderr and os.environ

    Usage::

        CGIHandler().run(app)

    The difference between this class and BaseCGIHandler is that it always
    uses 'wsgi.run_once' of 'True', 'wsgi.multithread' of 'False', and
    'wsgi.multiprocess' of 'True'.  It does not take any initialization
    parameters, but always uses 'sys.stdin', 'os.environ', and friends.

    If you need to override any of these parameters, use BaseCGIHandler
    instead.
    c
CsAtj|tjtjtjttjj	��dt
dt�dS(NR�R�(RR�RuR~RRsR
R}R1R	RgRj(R7((s(/usr/lib64/python2.7/wsgiref/handlers.pyR��s*(RzR{R|RjRAR;R�(((s(/usr/lib64/python2.7/wsgiref/handlers.pyR�s(R|ttypesRtutilRRRRVRRuR}R!t__all__R
t	NameErrorR#RFR$R/RRRR(((s(/usr/lib64/python2.7/wsgiref/handlers.pyt<module>s&$

	�=)__init__.pyc000064400000001331150327210740007017 0ustar00�
{fc@s
dZdS(sCwsgiref -- a WSGI (PEP 333) Reference Library

Current Contents:

* util -- Miscellaneous useful functions and wrappers

* headers -- Manage response headers

* handlers -- base classes for server/gateway implementations

* simple_server -- a simple BaseHTTPServer that supports WSGI

* validate -- validation wrapper that sits between an app and a server
  to detect errors in either

To-Do:

* cgi_gateway -- Run WSGI apps under CGI (pending a deployment standard)

* cgi_wrapper -- Run CGI apps under WSGI

* router -- a simple middleware component that handles URL traversal
N(t__doc__(((s(/usr/lib64/python2.7/wsgiref/__init__.pyt<module>tvalidate.pyo000064400000040725150327210740007077 0ustar00�
{fc@sFdZdgZddlZddlZddlmZmZmZmZddl	Z	ej
d�Zej
d�Zde
fd��YZd	�Zd
�Zddd��YZd
dd��YZddd��YZdd d��YZdd!d��YZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS("s"
Middleware to check for obedience to the WSGI specification.

Some of the things this checks:

* Signature of the application and start_response (including that
  keyword arguments are not used).

* Environment checks:

  - Environment is a dictionary (and not a subclass).

  - That all the required keys are in the environment: REQUEST_METHOD,
    SERVER_NAME, SERVER_PORT, wsgi.version, wsgi.input, wsgi.errors,
    wsgi.multithread, wsgi.multiprocess, wsgi.run_once

  - That HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH are not in the
    environment (these headers should appear as CONTENT_LENGTH and
    CONTENT_TYPE).

  - Warns if QUERY_STRING is missing, as the cgi module acts
    unpredictably in that case.

  - That CGI-style variables (that don't contain a .) have
    (non-unicode) string values

  - That wsgi.version is a tuple

  - That wsgi.url_scheme is 'http' or 'https' (@@: is this too
    restrictive?)

  - Warns if the REQUEST_METHOD is not known (@@: probably too
    restrictive).

  - That SCRIPT_NAME and PATH_INFO are empty or start with /

  - That at least one of SCRIPT_NAME or PATH_INFO are set.

  - That CONTENT_LENGTH is a positive integer.

  - That SCRIPT_NAME is not '/' (it should be '', and PATH_INFO should
    be '/').

  - That wsgi.input has the methods read, readline, readlines, and
    __iter__

  - That wsgi.errors has the methods flush, write, writelines

* The status is a string, contains a space, starts with an integer,
  and that integer is in range (> 100).

* That the headers is a list (not a subclass, not another kind of
  sequence).

* That the items of the headers are tuples of strings.

* That there is no 'status' header (that is used in CGI, but not in
  WSGI).

* That the headers don't contain newlines or colons, end in _ or -, or
  contain characters codes below 037.

* That Content-Type is given if there is content (CGI often has a
  default content type, but WSGI does not).

* That no Content-Type is given when there is no content (@@: is this
  too restrictive?)

* That the exc_info argument to start_response is a tuple or None.

* That all calls to the writer are with strings, and no other methods
  on the writer are accessed.

* That wsgi.input is used properly:

  - .read() is called with zero or one argument

  - That it returns a string

  - That readline, readlines, and __iter__ return strings

  - That .close() is not called

  - No other methods are provided

* That wsgi.errors is used properly:

  - .write() and .writelines() is called with a string

  - That .close() is not called, and no other methods are provided.

* The response iterator:

  - That it is not a string (it should be a list of a single string; a
    string will work, but perform horribly).

  - That .next() returns a string

  - That the iterator is not iterated over until start_response has
    been called (that can signal either a server or application
    error).

  - That .close() is called (doesn't raise exception, only prints to
    sys.stderr, because we only know it isn't called when the object
    is garbage collected).
t	validatori����N(tDictTypet
StringTypet	TupleTypetListTypes^[a-zA-Z][a-zA-Z0-9\-_]*$s[\000-\037]tWSGIWarningcBseZdZRS(s:
    Raised in response to WSGI-spec-related warnings
    (t__name__t
__module__t__doc__(((s(/usr/lib64/python2.7/wsgiref/validate.pyRzscGs|st|��ndS(N(tAssertionError(tcondtargs((s(/usr/lib64/python2.7/wsgiref/validate.pytassert_scs�fd�}|S(s�
    When applied between a WSGI server and a WSGI application, this
    middleware will check for WSGI compliancy on a number of levels.
    This middleware does not modify the request or response in any
    way, but will raise an AssertionError if anything seems off
    (except for a failure to close the application iterator, which
    will be printed to stderr -- there's no way to raise an exception
    at that point).
    cs�tt|�dkd�t|d�|\}�t|�g���fd�}t|d�|d<t|d�|d<�||�}t|dk	o�|tkd�t|�t|��S(NisTwo arguments requiredsNo keyword arguments allowedcs�tt|�dkp$t|�dkd|f�t|d�|d}|d}t|�dkrs|d}nd}t|�t|�t||�t|��jd�t�|��S(NiisInvalid number of arguments: %ssNo keyword arguments allowedii(	RtlentNonetcheck_statust
check_headerstcheck_content_typetcheck_exc_infotappendtWriteWrapper(Rtkwtstatustheaderstexc_info(tstart_responsetstart_response_started(s(/usr/lib64/python2.7/wsgiref/validate.pytstart_response_wrapper�s$







s
wsgi.inputswsgi.errorss>The application must return an iterator, if only an empty list(	RR
t
check_environtInputWrappertErrorWrapperRtFalsetcheck_iteratortIteratorWrapper(RRtenvironRtiterator(tapplication(RRs(/usr/lib64/python2.7/wsgiref/validate.pytlint_app�s

((R$R%((R$s(/usr/lib64/python2.7/wsgiref/validate.pyR�s)RcBs>eZd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs
||_dS(N(tinput(tselft
wsgi_input((s(/usr/lib64/python2.7/wsgiref/validate.pyt__init__�scGsHtt|�dk�|jj|�}tt|�td�k�|S(Nit(RR
R&treadttype(R'Rtv((s(/usr/lib64/python2.7/wsgiref/validate.pyR+�scCs/|jj�}tt|�td�k�|S(NR*(R&treadlineRR,(R'R-((s(/usr/lib64/python2.7/wsgiref/validate.pyR.�scGsutt|�dk�|jj|�}tt|�tg�k�x*|D]"}tt|�td�k�qKW|S(NiR*(RR
R&t	readlinesR,(R'Rtlinestline((s(/usr/lib64/python2.7/wsgiref/validate.pyR/�s
 ccs&x|j�}|sdS|VqWdS(N(R.(R'R1((s(/usr/lib64/python2.7/wsgiref/validate.pyt__iter__�s
cCstdd�dS(Nis input.close() must not be called(R(R'((s(/usr/lib64/python2.7/wsgiref/validate.pytclose�s(RRR)R+R.R/R2R3(((s(/usr/lib64/python2.7/wsgiref/validate.pyR�s					RcBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCs
||_dS(N(terrors(R'twsgi_errors((s(/usr/lib64/python2.7/wsgiref/validate.pyR)�scCs0tt|�td�k�|jj|�dS(NR*(RR,R4twrite(R'ts((s(/usr/lib64/python2.7/wsgiref/validate.pyR6�scCs|jj�dS(N(R4tflush(R'((s(/usr/lib64/python2.7/wsgiref/validate.pyR8�scCs"x|D]}|j|�qWdS(N(R6(R'tseqR1((s(/usr/lib64/python2.7/wsgiref/validate.pyt
writelines�s
cCstdd�dS(Nis!errors.close() must not be called(R(R'((s(/usr/lib64/python2.7/wsgiref/validate.pyR3�s(RRR)R6R8R:R3(((s(/usr/lib64/python2.7/wsgiref/validate.pyR�s
				RcBseZd�Zd�ZRS(cCs
||_dS(N(twriter(R'twsgi_writer((s(/usr/lib64/python2.7/wsgiref/validate.pyR)�scCs-tt|�td�k�|j|�dS(NR*(RR,R;(R'R7((s(/usr/lib64/python2.7/wsgiref/validate.pyt__call__�s(RRR)R=(((s(/usr/lib64/python2.7/wsgiref/validate.pyR�s	tPartialIteratorWrappercBseZd�Zd�ZRS(cCs
||_dS(N(R#(R't
wsgi_iterator((s(/usr/lib64/python2.7/wsgiref/validate.pyR)�scCst|jd�S(N(R!R#R(R'((s(/usr/lib64/python2.7/wsgiref/validate.pyR2�s(RRR)R2(((s(/usr/lib64/python2.7/wsgiref/validate.pyR>�s	R!cBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCs.||_t|�|_t|_||_dS(N(toriginal_iteratortiterR#Rtclosedtcheck_start_response(R'R?RC((s(/usr/lib64/python2.7/wsgiref/validate.pyR)s		cCs|S(N((R'((s(/usr/lib64/python2.7/wsgiref/validate.pyR2	scCsOt|jd�|jj�}|jdk	rKt|jd�d|_n|S(NsIterator read after closedsjThe application returns and we started iterating over its body, but start_response has not yet been called(RRBR#tnextRCR(R'R-((s(/usr/lib64/python2.7/wsgiref/validate.pyRDs
	cCs/t|_t|jd�r+|jj�ndS(NR3(tTrueRBthasattrR@R3(R'((s(/usr/lib64/python2.7/wsgiref/validate.pyR3s	cCs0|jstjjd�nt|jd�dS(Ns/Iterator garbage collected without being closed(RBtsyststderrR6R(R'((s(/usr/lib64/python2.7/wsgiref/validate.pyt__del__s
		
	(RRR)R2RDR3RI(((s(/usr/lib64/python2.7/wsgiref/validate.pyR!s
			
	c	Cs�tt|�tkdt|�|f�xCdddddddd	d
g	D] }t||kd|f�qKWx5dd
gD]'}t||kd||df�q|Wd|kr�tjdt�nx^|j�D]P}d|kr�q�ntt||�tkd|t||�||f�q�Wtt|d�tkd|df�t|dd,kd|d�t	|d�t
|d�|dd-kr�tjd!|dt�nt|jd"�p�|d"jd#�d$|d"�t|jd%�p
|d%jd#�d&|d%�|jd'�rPtt
|d'�d(kd)|d'�n|jd"�sutd%|kd*�nt|jd"�d#kd+�dS(.Ns:Environment is not of the right type: %r (environment: %r)tREQUEST_METHODtSERVER_NAMEtSERVER_PORTswsgi.versions
wsgi.inputswsgi.errorsswsgi.multithreadswsgi.multiprocesss
wsgi.run_onces$Environment missing required key: %rtHTTP_CONTENT_TYPEtHTTP_CONTENT_LENGTHs8Environment should not have the key: %s (use %s instead)itQUERY_STRINGs�QUERY_STRING is not in the WSGI environment; the cgi module will use sys.argv when this variable is missing, so application errors are more likelyt.s9Environmental variable %s is not a string: %r (value: %r)s#wsgi.version should be a tuple (%r)swsgi.url_schemethttpthttpsswsgi.url_scheme unknown: %rtGETtHEADtPOSTtOPTIONStPATCHtPUTtDELETEtTRACEsUnknown REQUEST_METHOD: %rtSCRIPT_NAMEt/s$SCRIPT_NAME doesn't start with /: %rt	PATH_INFOs"PATH_INFO doesn't start with /: %rtCONTENT_LENGTHisInvalid CONTENT_LENGTH: %rsgOne of SCRIPT_NAME or PATH_INFO are required (PATH_INFO should at least be '/' if SCRIPT_NAME is empty)sOSCRIPT_NAME cannot be '/'; it should instead be '', and PATH_INFO should be '/'(RQRR(RSRTRURVRWRXRYRZ(RR,RtwarningstwarnRtkeysRRtcheck_inputtcheck_errorstgett
startswithtint(R"tkey((s(/usr/lib64/python2.7/wsgiref/validate.pyR"s`	

#	

cCsAx:ddddgD]&}tt||�d||f�qWdS(NR+R.R/R2s-wsgi.input (%r) doesn't have the attribute %s(RRF(R(tattr((s(/usr/lib64/python2.7/wsgiref/validate.pyRbcscCs>x7dddgD]&}tt||�d||f�qWdS(NR8R6R:s.wsgi.errors (%r) doesn't have the attribute %s(RRF(R5Rh((s(/usr/lib64/python2.7/wsgiref/validate.pyRciscCs�tt|�tkd|�|jdd�d}tt|�dkd|�t|�}t|dkd|�t|�dks�|dd	kr�tjd
|t	�ndS(Ns Status must be a string (not %r)iiis)Status codes must be three characters: %ridsStatus code is invalid: %rit sjThe status string (%r) should be a three-digit integer followed by a single space and a status explanation(
RR,RtsplitRR
RfR_R`R(Rtstatus_codet
status_int((s(/usr/lib64/python2.7/wsgiref/validate.pyRos"cCs_tt|�tkd|t|�f�i}x)|D]!}tt|�tkd|t|�f�tt|�dk�|\}}t|j�dkd|�d||j�<td|ko�d|kd|�ttj|�d	|�t|j	d
�o|j	d�d|�t
j|�r6td
d|t
j|�jd
�f�q6q6WdS(Ns%Headers (%r) must be of type list: %rs1Individual headers (%r) must be of type tuple: %riRsyThe Status header cannot be used; it conflicts with CGI script, and HTTP status is not given through headers (value: %r).s
t:s,Header names may not contain ':' or '\n': %rsBad header name: %rt-t_s#Names may not end in '-' or '_': %ris#Bad header value: %r (bad char: %r)(RR,RRR
tlowerRt	header_retsearchtendswithtbad_header_value_retgroup(Rtheader_namestitemtnametvalue((s(/usr/lib64/python2.7/wsgiref/validate.pyR~s,
 	cCs�t|jdd�d�}d}xJ|D]B\}}|j�dkr)||krWdStdd|�q)q)W||kr�tdd|�ndS(	Niii�i0scontent-typesJContent-Type header found in a %s response, which must not return content.s,No Content-Type header found in headers (%s)(i�i0(RfRjRRpR(RRtcodetNO_MESSAGE_BODYRxRy((s(/usr/lib64/python2.7/wsgiref/validate.pyR�s	cCs?t|dkp$t|�td�kd|t|�f�dS(Ns exc_info (%r) is not a tuple: %r((RRR,(R((s(/usr/lib64/python2.7/wsgiref/validate.pyR�s$cCstt|t�d�dS(NsvYou should not return a string as your application iterator, instead return a single-item list containing that string.(Rt
isinstancetstr(R#((s(/usr/lib64/python2.7/wsgiref/validate.pyR �s((((((Rt__all__treRGttypesRRRRR_tcompileRqRttWarningRRRRRRR>R!RRbRcRRRRR (((s(/usr/lib64/python2.7/wsgiref/validate.pyt<module>ns.	"		7"		!	A						__pycache__/validate.cpython-36.pyc000064400000034722150327211600013200 0ustar003


 \;;�@s�dZdgZddlZddlZddlZejd�Zejd�ZGdd�de�Z	dd	�Z
d
d�Zdd�ZGd
d�d�Z
Gdd�d�ZGdd�d�ZGdd�d�ZGdd�d�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdS)'a&
Middleware to check for obedience to the WSGI specification.

Some of the things this checks:

* Signature of the application and start_response (including that
  keyword arguments are not used).

* Environment checks:

  - Environment is a dictionary (and not a subclass).

  - That all the required keys are in the environment: REQUEST_METHOD,
    SERVER_NAME, SERVER_PORT, wsgi.version, wsgi.input, wsgi.errors,
    wsgi.multithread, wsgi.multiprocess, wsgi.run_once

  - That HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH are not in the
    environment (these headers should appear as CONTENT_LENGTH and
    CONTENT_TYPE).

  - Warns if QUERY_STRING is missing, as the cgi module acts
    unpredictably in that case.

  - That CGI-style variables (that don't contain a .) have
    (non-unicode) string values

  - That wsgi.version is a tuple

  - That wsgi.url_scheme is 'http' or 'https' (@@: is this too
    restrictive?)

  - Warns if the REQUEST_METHOD is not known (@@: probably too
    restrictive).

  - That SCRIPT_NAME and PATH_INFO are empty or start with /

  - That at least one of SCRIPT_NAME or PATH_INFO are set.

  - That CONTENT_LENGTH is a positive integer.

  - That SCRIPT_NAME is not '/' (it should be '', and PATH_INFO should
    be '/').

  - That wsgi.input has the methods read, readline, readlines, and
    __iter__

  - That wsgi.errors has the methods flush, write, writelines

* The status is a string, contains a space, starts with an integer,
  and that integer is in range (> 100).

* That the headers is a list (not a subclass, not another kind of
  sequence).

* That the items of the headers are tuples of strings.

* That there is no 'status' header (that is used in CGI, but not in
  WSGI).

* That the headers don't contain newlines or colons, end in _ or -, or
  contain characters codes below 037.

* That Content-Type is given if there is content (CGI often has a
  default content type, but WSGI does not).

* That no Content-Type is given when there is no content (@@: is this
  too restrictive?)

* That the exc_info argument to start_response is a tuple or None.

* That all calls to the writer are with strings, and no other methods
  on the writer are accessed.

* That wsgi.input is used properly:

  - .read() is called with zero or one argument

  - That it returns a string

  - That readline, readlines, and __iter__ return strings

  - That .close() is not called

  - No other methods are provided

* That wsgi.errors is used properly:

  - .write() and .writelines() is called with a string

  - That .close() is not called, and no other methods are provided.

* The response iterator:

  - That it is not a string (it should be a list of a single string; a
    string will work, but perform horribly).

  - That .__next__() returns a string

  - That the iterator is not iterated over until start_response has
    been called (that can signal either a server or application
    error).

  - That .close() is called (doesn't raise exception, only prints to
    sys.stderr, because we only know it isn't called when the object
    is garbage collected).
�	validator�Nz^[a-zA-Z][a-zA-Z0-9\-_]*$z[\000-\037]c@seZdZdZdS)�WSGIWarningz:
    Raised in response to WSGI-spec-related warnings
    N)�__name__�
__module__�__qualname__�__doc__�rr�(/usr/lib64/python3.6/wsgiref/validate.pyrysrcGs|st|��dS)N)�AssertionError)Zcond�argsrrr	�assert_~srcCs(t|�tkr|Stdj|t|����dS)Nz!{0} must be of type str (got {1}))�type�strr
�format�repr)�value�titlerrr	�check_string_type�srcs�fdd�}|S)a�
    When applied between a WSGI server and a WSGI application, this
    middleware will check for WSGI compliancy on a number of levels.
    This middleware does not modify the request or response in any
    way, but will raise an AssertionError if anything seems off
    (except for a failure to close the application iterator, which
    will be printed to stderr -- there's no way to raise an exception
    at that point).
    cs�tt|�dkd�t|d�|\}�t|�g���fdd�}t|d�|d<t|d�|d<�||�}t|dk	oz|dkd	�t|�t|��S)
N�zTwo arguments requiredzNo keyword arguments allowedcs�tt|�dkpt|�dkd|f�t|d�|d}|d}t|�dkrV|d}nd}t|�t|�t||�t|��jd�t�|��S)Nr�zInvalid number of arguments: %szNo keyword arguments allowedr�)r�len�check_status�
check_headers�check_content_type�check_exc_info�append�WriteWrapper)r�kw�status�headers�exc_info)�start_response�start_response_startedrr	�start_response_wrapper�s


z;validator.<locals>.lint_app.<locals>.start_response_wrapperz
wsgi.inputzwsgi.errorsFz>The application must return an iterator, if only an empty list)rr�
check_environ�InputWrapper�ErrorWrapper�check_iterator�IteratorWrapper)rr�environr$�iterator)�application)r"r#r	�lint_app�s
zvalidator.<locals>.lint_appr)r,r-r)r,r	r�s)c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)r&cCs
||_dS)N)�input)�self�
wsgi_inputrrr	�__init__�szInputWrapper.__init__cGs0tt|�dk�|jj|�}tt|�tk�|S)Nr)rrr.�readr
�bytes)r/r�vrrr	r2�szInputWrapper.readcGs0tt|�dk�|jj|�}tt|�tk�|S)Nr)rrr.�readliner
r3)r/rr4rrr	r5�szInputWrapper.readlinecGsNtt|�dk�|jj|�}tt|�tk�x|D]}tt|�tk�q2W|S)Nr)rrr.�	readlinesr
�listr3)r/r�lines�linerrr	r6�s
zInputWrapper.readlinesccs x|j�}|sdS|VqWdS)N)r5)r/r9rrr	�__iter__�s
zInputWrapper.__iter__cCstdd�dS)Nrz input.close() must not be called)r)r/rrr	�close�szInputWrapper.closeN)	rrrr1r2r5r6r:r;rrrr	r&�sr&c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r'cCs
||_dS)N)�errors)r/�wsgi_errorsrrr	r1�szErrorWrapper.__init__cCs tt|�tk�|jj|�dS)N)rr
rr<�write)r/�srrr	r>�szErrorWrapper.writecCs|jj�dS)N)r<�flush)r/rrr	r@�szErrorWrapper.flushcCsx|D]}|j|�qWdS)N)r>)r/�seqr9rrr	�
writelines�s
zErrorWrapper.writelinescCstdd�dS)Nrz!errors.close() must not be called)r)r/rrr	r;�szErrorWrapper.closeN)rrrr1r>r@rBr;rrrr	r'�s
r'c@seZdZdd�Zdd�ZdS)rcCs
||_dS)N)�writer)r/Zwsgi_writerrrr	r1�szWriteWrapper.__init__cCstt|�tk�|j|�dS)N)rr
r3rC)r/r?rrr	�__call__�szWriteWrapper.__call__N)rrrr1rDrrrr	r�src@seZdZdd�Zdd�ZdS)�PartialIteratorWrappercCs
||_dS)N)r+)r/�
wsgi_iteratorrrr	r1szPartialIteratorWrapper.__init__cCst|jd�S)N)r)r+)r/rrr	r:szPartialIteratorWrapper.__iter__N)rrrr1r:rrrr	rE�srEc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r)cCs ||_t|�|_d|_||_dS)NF)�original_iterator�iterr+�closed�check_start_response)r/rFrJrrr	r1	s
zIteratorWrapper.__init__cCs|S)Nr)r/rrr	r:szIteratorWrapper.__iter__cCsTt|jd�t|j�}t|�tk	r4tdd|f�|jdk	rPt|jd�d|_|S)NzIterator read after closedFz$Iterator yielded non-bytestring (%r)zjThe application returns and we started iterating over its body, but start_response has not yet been called)rrI�nextr+r
r3rJ)r/r4rrr	�__next__s

zIteratorWrapper.__next__cCs d|_t|jd�r|jj�dS)NTr;)rI�hasattrrGr;)r/rrr	r;szIteratorWrapper.closecCs"|jstjjd�t|jd�dS)Nz/Iterator garbage collected without being closed)rI�sys�stderrr>r)r/rrr	�__del__#s
zIteratorWrapper.__del__N)rrrr1r:rLr;rPrrrr	r)s
r)c	Cs�tt|�tkdt|�|f�x d,D]}t||kd|f�q$Wx*d-D]"}t||kd||dd�f�qFWd|kr�tjdt�xF|j�D]:}d|kr�q�tt||�tkd|t||�||f�q�Wtt|d�tkd|df�t|dd.kd|d�t	|d�t
|d�|dd/k�r<tjd!|dt�t|jd"��pX|d"jd#�d$|d"�t|jd%��p�|d%jd#�d&|d%�|jd'��r�tt
|d'�d(kd)|d'�|jd"��s�td%|kd*�t|jd"�d#kd+�dS)0Nz:Environment is not of the right type: %r (environment: %r)�REQUEST_METHOD�SERVER_NAME�SERVER_PORT�wsgi.version�
wsgi.input�wsgi.errors�wsgi.multithread�wsgi.multiprocess�
wsgi.run_oncez$Environment missing required key: %r�HTTP_CONTENT_TYPE�HTTP_CONTENT_LENGTHz8Environment should not have the key: %s (use %s instead)�ZQUERY_STRINGz�QUERY_STRING is not in the WSGI environment; the cgi module will use sys.argv when this variable is missing, so application errors are more likely�.z9Environmental variable %s is not a string: %r (value: %r)z#wsgi.version should be a tuple (%r)zwsgi.url_scheme�http�httpszwsgi.url_scheme unknown: %r�GET�HEAD�POST�OPTIONS�PATCH�PUT�DELETE�TRACEzUnknown REQUEST_METHOD: %rZSCRIPT_NAME�/z$SCRIPT_NAME doesn't start with /: %rZ	PATH_INFOz"PATH_INFO doesn't start with /: %rZCONTENT_LENGTHrzInvalid CONTENT_LENGTH: %rzgOne of SCRIPT_NAME or PATH_INFO are required (PATH_INFO should at least be '/' if SCRIPT_NAME is empty)zOSCRIPT_NAME cannot be '/'; it should instead be '', and PATH_INFO should be '/')	rQrRrSrTrUrVrWrXrY)rZr[)r^r_)r`rarbrcrdrerfrg)rr
�dict�warnings�warnr�keysr�tuple�check_input�check_errors�get�
startswith�int)r*�keyrrr	r%*s`

r%cCs*x$dD]}tt||�d||f�qWdS)Nr2r5r6r:z-wsgi.input (%r) doesn't have the attribute %s)r2r5r6r:)rrM)r0�attrrrr	rnks

rncCs*x$dD]}tt||�d||f�qWdS)Nr@r>rBz.wsgi.errors (%r) doesn't have the attribute %s)r@r>rB)rrM)r=rtrrr	roqs

rocCsvt|d�}|jdd�d}tt|�dkd|�t|�}t|dkd|�t|�dksb|dd	krrtjd
|t�dS)N�Statusrrrz)Status codes must be three characters: %r�dzStatus code is invalid: %r�� zjThe status string (%r) should be a three-digit integer followed by a single space and a status explanation)r�splitrrrrrjrkr)rZstatus_codeZ
status_intrrr	rws

rcCstt|�tkd|t|�f�i}x�|D]�}tt|�tkd|t|�f�tt|�dk�|\}}t|d�}t|d�}t|j�dkd|�d||j�<td|ko�d	|kd
|�ttj|�d|�t|j	d�o�|j	d
�d|�t
j|�r(tdd|t
j|�jd�f�q(WdS)Nz%Headers (%r) must be of type list: %rz1Individual headers (%r) must be of type tuple: %rrzHeader namezHeader valuerzyThe Status header cannot be used; it conflicts with CGI script, and HTTP status is not given through headers (value: %r).�
�:z,Header names may not contain ':' or '\n': %rzBad header name: %r�-�_z#Names may not end in '-' or '_': %rrz#Bad header value: %r (bad char: %r))rr
r7rmrr�lower�	header_re�search�endswith�bad_header_value_re�group)r Zheader_names�item�namerrrr	r�s0





rcCs~t|d�}t|jdd�d�}d
}x@|D]8\}}t|d�}|j�dkr(||krRdStdd|�q(W||krztdd	|�dS)Nrurr���0zHeader namezcontent-typezJContent-Type header found in a %s response, which must not return content.z,No Content-Type header found in headers (%s))r�r�)rrrryr~r)rr �codeZNO_MESSAGE_BODYr�rrrr	r�s

rcCs*t|dkpt|�tkd|t|�f�dS)Nz exc_info (%r) is not a tuple: %r)rr
rm)r!rrr	r�srcCstt|ttf�d�dS)NzwYou should not return a string as your application iterator, instead return a single-item list containing a bytestring.)r�
isinstancerr3)r+rrr	r(�sr()r�__all__�rerNrj�compilerr��Warningrrrrr&r'rrEr)r%rnrorrrrr(rrrr	�<module>ns.

7#		#A__pycache__/__init__.cpython-36.opt-2.pyc000064400000000175150327211600014101 0ustar003


 \K�@sdS)N�rrr�(/usr/lib64/python3.6/wsgiref/__init__.py�<module>s__pycache__/validate.cpython-36.opt-1.pyc000064400000034722150327211600014137 0ustar003


 \;;�@s�dZdgZddlZddlZddlZejd�Zejd�ZGdd�de�Z	dd	�Z
d
d�Zdd�ZGd
d�d�Z
Gdd�d�ZGdd�d�ZGdd�d�ZGdd�d�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdS)'a&
Middleware to check for obedience to the WSGI specification.

Some of the things this checks:

* Signature of the application and start_response (including that
  keyword arguments are not used).

* Environment checks:

  - Environment is a dictionary (and not a subclass).

  - That all the required keys are in the environment: REQUEST_METHOD,
    SERVER_NAME, SERVER_PORT, wsgi.version, wsgi.input, wsgi.errors,
    wsgi.multithread, wsgi.multiprocess, wsgi.run_once

  - That HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH are not in the
    environment (these headers should appear as CONTENT_LENGTH and
    CONTENT_TYPE).

  - Warns if QUERY_STRING is missing, as the cgi module acts
    unpredictably in that case.

  - That CGI-style variables (that don't contain a .) have
    (non-unicode) string values

  - That wsgi.version is a tuple

  - That wsgi.url_scheme is 'http' or 'https' (@@: is this too
    restrictive?)

  - Warns if the REQUEST_METHOD is not known (@@: probably too
    restrictive).

  - That SCRIPT_NAME and PATH_INFO are empty or start with /

  - That at least one of SCRIPT_NAME or PATH_INFO are set.

  - That CONTENT_LENGTH is a positive integer.

  - That SCRIPT_NAME is not '/' (it should be '', and PATH_INFO should
    be '/').

  - That wsgi.input has the methods read, readline, readlines, and
    __iter__

  - That wsgi.errors has the methods flush, write, writelines

* The status is a string, contains a space, starts with an integer,
  and that integer is in range (> 100).

* That the headers is a list (not a subclass, not another kind of
  sequence).

* That the items of the headers are tuples of strings.

* That there is no 'status' header (that is used in CGI, but not in
  WSGI).

* That the headers don't contain newlines or colons, end in _ or -, or
  contain characters codes below 037.

* That Content-Type is given if there is content (CGI often has a
  default content type, but WSGI does not).

* That no Content-Type is given when there is no content (@@: is this
  too restrictive?)

* That the exc_info argument to start_response is a tuple or None.

* That all calls to the writer are with strings, and no other methods
  on the writer are accessed.

* That wsgi.input is used properly:

  - .read() is called with zero or one argument

  - That it returns a string

  - That readline, readlines, and __iter__ return strings

  - That .close() is not called

  - No other methods are provided

* That wsgi.errors is used properly:

  - .write() and .writelines() is called with a string

  - That .close() is not called, and no other methods are provided.

* The response iterator:

  - That it is not a string (it should be a list of a single string; a
    string will work, but perform horribly).

  - That .__next__() returns a string

  - That the iterator is not iterated over until start_response has
    been called (that can signal either a server or application
    error).

  - That .close() is called (doesn't raise exception, only prints to
    sys.stderr, because we only know it isn't called when the object
    is garbage collected).
�	validator�Nz^[a-zA-Z][a-zA-Z0-9\-_]*$z[\000-\037]c@seZdZdZdS)�WSGIWarningz:
    Raised in response to WSGI-spec-related warnings
    N)�__name__�
__module__�__qualname__�__doc__�rr�(/usr/lib64/python3.6/wsgiref/validate.pyrysrcGs|st|��dS)N)�AssertionError)Zcond�argsrrr	�assert_~srcCs(t|�tkr|Stdj|t|����dS)Nz!{0} must be of type str (got {1}))�type�strr
�format�repr)�value�titlerrr	�check_string_type�srcs�fdd�}|S)a�
    When applied between a WSGI server and a WSGI application, this
    middleware will check for WSGI compliancy on a number of levels.
    This middleware does not modify the request or response in any
    way, but will raise an AssertionError if anything seems off
    (except for a failure to close the application iterator, which
    will be printed to stderr -- there's no way to raise an exception
    at that point).
    cs�tt|�dkd�t|d�|\}�t|�g���fdd�}t|d�|d<t|d�|d<�||�}t|dk	oz|dkd	�t|�t|��S)
N�zTwo arguments requiredzNo keyword arguments allowedcs�tt|�dkpt|�dkd|f�t|d�|d}|d}t|�dkrV|d}nd}t|�t|�t||�t|��jd�t�|��S)Nr�zInvalid number of arguments: %szNo keyword arguments allowedr�)r�len�check_status�
check_headers�check_content_type�check_exc_info�append�WriteWrapper)r�kw�status�headers�exc_info)�start_response�start_response_startedrr	�start_response_wrapper�s


z;validator.<locals>.lint_app.<locals>.start_response_wrapperz
wsgi.inputzwsgi.errorsFz>The application must return an iterator, if only an empty list)rr�
check_environ�InputWrapper�ErrorWrapper�check_iterator�IteratorWrapper)rr�environr$�iterator)�application)r"r#r	�lint_app�s
zvalidator.<locals>.lint_appr)r,r-r)r,r	r�s)c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)r&cCs
||_dS)N)�input)�self�
wsgi_inputrrr	�__init__�szInputWrapper.__init__cGs0tt|�dk�|jj|�}tt|�tk�|S)Nr)rrr.�readr
�bytes)r/r�vrrr	r2�szInputWrapper.readcGs0tt|�dk�|jj|�}tt|�tk�|S)Nr)rrr.�readliner
r3)r/rr4rrr	r5�szInputWrapper.readlinecGsNtt|�dk�|jj|�}tt|�tk�x|D]}tt|�tk�q2W|S)Nr)rrr.�	readlinesr
�listr3)r/r�lines�linerrr	r6�s
zInputWrapper.readlinesccs x|j�}|sdS|VqWdS)N)r5)r/r9rrr	�__iter__�s
zInputWrapper.__iter__cCstdd�dS)Nrz input.close() must not be called)r)r/rrr	�close�szInputWrapper.closeN)	rrrr1r2r5r6r:r;rrrr	r&�sr&c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r'cCs
||_dS)N)�errors)r/�wsgi_errorsrrr	r1�szErrorWrapper.__init__cCs tt|�tk�|jj|�dS)N)rr
rr<�write)r/�srrr	r>�szErrorWrapper.writecCs|jj�dS)N)r<�flush)r/rrr	r@�szErrorWrapper.flushcCsx|D]}|j|�qWdS)N)r>)r/�seqr9rrr	�
writelines�s
zErrorWrapper.writelinescCstdd�dS)Nrz!errors.close() must not be called)r)r/rrr	r;�szErrorWrapper.closeN)rrrr1r>r@rBr;rrrr	r'�s
r'c@seZdZdd�Zdd�ZdS)rcCs
||_dS)N)�writer)r/Zwsgi_writerrrr	r1�szWriteWrapper.__init__cCstt|�tk�|j|�dS)N)rr
r3rC)r/r?rrr	�__call__�szWriteWrapper.__call__N)rrrr1rDrrrr	r�src@seZdZdd�Zdd�ZdS)�PartialIteratorWrappercCs
||_dS)N)r+)r/�
wsgi_iteratorrrr	r1szPartialIteratorWrapper.__init__cCst|jd�S)N)r)r+)r/rrr	r:szPartialIteratorWrapper.__iter__N)rrrr1r:rrrr	rE�srEc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r)cCs ||_t|�|_d|_||_dS)NF)�original_iterator�iterr+�closed�check_start_response)r/rFrJrrr	r1	s
zIteratorWrapper.__init__cCs|S)Nr)r/rrr	r:szIteratorWrapper.__iter__cCsTt|jd�t|j�}t|�tk	r4tdd|f�|jdk	rPt|jd�d|_|S)NzIterator read after closedFz$Iterator yielded non-bytestring (%r)zjThe application returns and we started iterating over its body, but start_response has not yet been called)rrI�nextr+r
r3rJ)r/r4rrr	�__next__s

zIteratorWrapper.__next__cCs d|_t|jd�r|jj�dS)NTr;)rI�hasattrrGr;)r/rrr	r;szIteratorWrapper.closecCs"|jstjjd�t|jd�dS)Nz/Iterator garbage collected without being closed)rI�sys�stderrr>r)r/rrr	�__del__#s
zIteratorWrapper.__del__N)rrrr1r:rLr;rPrrrr	r)s
r)c	Cs�tt|�tkdt|�|f�x d,D]}t||kd|f�q$Wx*d-D]"}t||kd||dd�f�qFWd|kr�tjdt�xF|j�D]:}d|kr�q�tt||�tkd|t||�||f�q�Wtt|d�tkd|df�t|dd.kd|d�t	|d�t
|d�|dd/k�r<tjd!|dt�t|jd"��pX|d"jd#�d$|d"�t|jd%��p�|d%jd#�d&|d%�|jd'��r�tt
|d'�d(kd)|d'�|jd"��s�td%|kd*�t|jd"�d#kd+�dS)0Nz:Environment is not of the right type: %r (environment: %r)�REQUEST_METHOD�SERVER_NAME�SERVER_PORT�wsgi.version�
wsgi.input�wsgi.errors�wsgi.multithread�wsgi.multiprocess�
wsgi.run_oncez$Environment missing required key: %r�HTTP_CONTENT_TYPE�HTTP_CONTENT_LENGTHz8Environment should not have the key: %s (use %s instead)�ZQUERY_STRINGz�QUERY_STRING is not in the WSGI environment; the cgi module will use sys.argv when this variable is missing, so application errors are more likely�.z9Environmental variable %s is not a string: %r (value: %r)z#wsgi.version should be a tuple (%r)zwsgi.url_scheme�http�httpszwsgi.url_scheme unknown: %r�GET�HEAD�POST�OPTIONS�PATCH�PUT�DELETE�TRACEzUnknown REQUEST_METHOD: %rZSCRIPT_NAME�/z$SCRIPT_NAME doesn't start with /: %rZ	PATH_INFOz"PATH_INFO doesn't start with /: %rZCONTENT_LENGTHrzInvalid CONTENT_LENGTH: %rzgOne of SCRIPT_NAME or PATH_INFO are required (PATH_INFO should at least be '/' if SCRIPT_NAME is empty)zOSCRIPT_NAME cannot be '/'; it should instead be '', and PATH_INFO should be '/')	rQrRrSrTrUrVrWrXrY)rZr[)r^r_)r`rarbrcrdrerfrg)rr
�dict�warnings�warnr�keysr�tuple�check_input�check_errors�get�
startswith�int)r*�keyrrr	r%*s`

r%cCs*x$dD]}tt||�d||f�qWdS)Nr2r5r6r:z-wsgi.input (%r) doesn't have the attribute %s)r2r5r6r:)rrM)r0�attrrrr	rnks

rncCs*x$dD]}tt||�d||f�qWdS)Nr@r>rBz.wsgi.errors (%r) doesn't have the attribute %s)r@r>rB)rrM)r=rtrrr	roqs

rocCsvt|d�}|jdd�d}tt|�dkd|�t|�}t|dkd|�t|�dksb|dd	krrtjd
|t�dS)N�Statusrrrz)Status codes must be three characters: %r�dzStatus code is invalid: %r�� zjThe status string (%r) should be a three-digit integer followed by a single space and a status explanation)r�splitrrrrrjrkr)rZstatus_codeZ
status_intrrr	rws

rcCstt|�tkd|t|�f�i}x�|D]�}tt|�tkd|t|�f�tt|�dk�|\}}t|d�}t|d�}t|j�dkd|�d||j�<td|ko�d	|kd
|�ttj|�d|�t|j	d�o�|j	d
�d|�t
j|�r(tdd|t
j|�jd�f�q(WdS)Nz%Headers (%r) must be of type list: %rz1Individual headers (%r) must be of type tuple: %rrzHeader namezHeader valuerzyThe Status header cannot be used; it conflicts with CGI script, and HTTP status is not given through headers (value: %r).�
�:z,Header names may not contain ':' or '\n': %rzBad header name: %r�-�_z#Names may not end in '-' or '_': %rrz#Bad header value: %r (bad char: %r))rr
r7rmrr�lower�	header_re�search�endswith�bad_header_value_re�group)r Zheader_names�item�namerrrr	r�s0





rcCs~t|d�}t|jdd�d�}d
}x@|D]8\}}t|d�}|j�dkr(||krRdStdd|�q(W||krztdd	|�dS)Nrurr���0zHeader namezcontent-typezJContent-Type header found in a %s response, which must not return content.z,No Content-Type header found in headers (%s))r�r�)rrrryr~r)rr �codeZNO_MESSAGE_BODYr�rrrr	r�s

rcCs*t|dkpt|�tkd|t|�f�dS)Nz exc_info (%r) is not a tuple: %r)rr
rm)r!rrr	r�srcCstt|ttf�d�dS)NzwYou should not return a string as your application iterator, instead return a single-item list containing a bytestring.)r�
isinstancerr3)r+rrr	r(�sr()r�__all__�rerNrj�compilerr��Warningrrrrr&r'rrEr)r%rnrorrrrr(rrrr	�<module>ns.

7#		#A__pycache__/headers.cpython-36.opt-2.pyc000064400000010531150327211600013752 0ustar003


 \n�@s.ddlZejd�Zddd�ZGdd�d�ZdS)	�Nz[ \(\)<>@,;:\\"/\[\]\?=]�cCsX|dk	rPt|�dkrP|s"tj|�rB|jdd�jdd�}d||fSd||fSn|SdS)Nr�\z\\�"z\"z%s="%s"z%s=%s)�len�	tspecials�search�replace)Zparam�valueZquote�r
�'/usr/lib64/python3.6/wsgiref/headers.py�_formatparam
src@s�eZdZd$dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
d%dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�ZdS)&�HeadersNcCs.|dk	r|ng}t|�tk	r$td��||_dS)Nz+Headers must be a list of name/value tuples)�type�list�	TypeError�_headers)�selfZheadersr
r
r�__init__s
zHeaders.__init__cCs&t|�tkr|Stdjt|����dS)Nz1Header names/values must be of type str (got {0}))r�str�AssertionError�format�repr)rr	r
r
r�_convert_string_type)szHeaders._convert_string_typecCs
t|j�S)N)rr)rr
r
r�__len__0szHeaders.__len__cCs&||=|jj|j|�|j|�f�dS)N)r�appendr)r�name�valr
r
r�__setitem__4szHeaders.__setitem__cs0|j�j����fdd�|jD�|jdd�<dS)Ncs g|]}|dj��kr|�qS)r)�lower)�.0�kv)rr
r�
<listcomp>@sz'Headers.__delitem__.<locals>.<listcomp>)rrr)rrr
)rr�__delitem__:szHeaders.__delitem__cCs
|j|�S)N)�get)rrr
r
r�__getitem__Bs	zHeaders.__getitem__cCs|j|�dk	S)N)r#)rrr
r
r�__contains__MszHeaders.__contains__cs"|j�j����fdd�|jD�S)Ncs$g|]}|dj��kr|d�qS)rr)r)rr )rr
rr![sz#Headers.get_all.<locals>.<listcomp>)rrr)rrr
)rr�get_allRszHeaders.get_allcCs6|j|j��}x"|jD]\}}|j�|kr|SqW|S)N)rrr)rr�default�k�vr
r
rr#^s
zHeaders.getcCsdd�|jD�S)NcSsg|]\}}|�qSr
r
)rr(r)r
r
rr!osz Headers.keys.<locals>.<listcomp>)r)rr
r
r�keysgszHeaders.keyscCsdd�|jD�S)NcSsg|]\}}|�qSr
r
)rr(r)r
r
rr!ysz"Headers.values.<locals>.<listcomp>)r)rr
r
r�valuesqszHeaders.valuescCs|jdd�S)N)r)rr
r
r�items{sz
Headers.itemscCsd|jj|jfS)Nz%s(%r))�	__class__�__name__r)rr
r
r�__repr__�szHeaders.__repr__cCsdjdd�|jD�ddg�S)Nz
cSsg|]}d|�qS)z%s: %sr
)rr r
r
rr!�sz#Headers.__str__.<locals>.<listcomp>�)�joinr)rr
r
r�__str__�szHeaders.__str__cCst|�jd�S)Nz
iso-8859-1)r�encode)rr
r
r�	__bytes__�szHeaders.__bytes__cCs:|j|�}|dkr2|jj|j|�|j|�f�|S|SdS)N)r#rrr)rrr	�resultr
r
r�
setdefault�s
zHeaders.setdefaultcKs�g}|dk	r |j|�}|j|�x\|j�D]P\}}|j|�}|dkrX|j|jdd��q*|j|�}|jt|jdd�|��q*W|jj|j|�dj|�f�dS)N�_�-z; )rrr,rrrr1)r�_nameZ_valueZ_params�partsr(r)r
r
r�
add_header�s



zHeaders.add_header)N)N)r.�
__module__�__qualname__rrrrr"r$r%r&r#r*r+r,r/r2r4r6r;r
r
r
rr
s"


	



r
)Nr)�re�compilerrr
r
r
r
r�<module>
s

__pycache__/handlers.cpython-36.pyc000064400000037426150327211600013213 0ustar003


 \	R�
@sdZddlmZmZmZddlmZddlZddlZddl	Z	dddd	d
dgZ
dd
dddddgZdddddddddddddg
Zdd �Z
d!d"d#d$d%d&d'd(d)d*h
jZd+d,�Zd-d�ZGd.d�d�ZGd/d�de�ZGd0d�de�ZGd1d	�d	e�ZGd2d
�d
e�ZdS)3z/Base classes for server/gateway implementations�)�FileWrapper�guess_scheme�
is_hop_by_hop)�Headers�N�BaseHandler�
SimpleHandler�BaseCGIHandler�
CGIHandler�
IISCGIHandler�read_environZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc
	Cs:tj|�\	}}}}}}}}}	dt||t|||||fS)Nz#%s, %02d %3s %4d %02d:%02d:%02d GMT)�timeZgmtime�_weekdayname�
_monthname)
Z	timestampZyearZmonthZdayZhhZmmZssZwd�y�z�r�(/usr/lib64/python3.6/wsgiref/handlers.py�format_date_timesr�SCRIPT_NAME�	PATH_INFOZQUERY_STRINGZREQUEST_METHODZ	AUTH_TYPEZCONTENT_TYPEZCONTENT_LENGTHZHTTPSZREMOTE_USERZREMOTE_IDENTcCs6t|�p4|jd�p4|jd�p4|jd�o4t|dd��S)NZHTTP_ZSSL_Z	REDIRECT_�	)�_is_request�
startswith�_needs_transcode)�krrrrsrcCs�tj�}d}ydjd|�Wntk
r4d}YnXi}x�tjj�D]�\}}t|�r�tjdkr�tjj	dd�j
�}|jd�r�|jd�jd�}q�|jd	�r�q�|jd
�r�d|kr�|jd�jd�}q�|j|d�jd�}n|j||�jd�}|||<qFW|S)z'Read environment, fixing HTTP variables�surrogateescape�zutf-8�replaceZwin32�SERVER_SOFTWAREzmicrosoft-iis/z
iso-8859-1zapache/zsimplehttp/zpython/3)
�sys�getfilesystemencoding�encode�LookupError�os�environ�itemsr�platform�get�lowerr�decode)�enc�escr%r�vZsoftwarerrrr"s,

	


c@s"eZdZdZd<ZdZdZdZdZdZ	dZ
e�Ze
ZeZdZdZd=gZdZdZZdZdZdZdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zd>dd�Z dd�Z!dd�Z"dd�Z#d d!�Z$d"d#�Z%d$d%�Z&d&d'�Z'd(d)�Z(d*d+�Z)d,d-�Z*d.d/�Z+d0d1�Z,d2d3�Z-d4d5�Z.d6d7�Z/d8d9�Z0d:d;�Z1dS)?rz+Manage the invocation of a WSGI applicationrrTFz1.0Nz500 Internal Server Error�Content-Type�
text/plains;A server error occurred.  Please contact the administrator.cCsZy$|j�||j|j�|_|j�Wn0y|j�Wn|j��YnXYnXdS)zInvoke the applicationN)�
setup_environr%�start_response�result�finish_response�handle_error�close)�selfZapplicationrrr�run�szBaseHandler.runcCs�|jj�}|_|j�|j�|d<|j�|d<|j|d<|j|d<|j�|d<|j	|d<|j
|d<|jdk	rx|j|d	<|jr�|j
r�|jd
|j
�dS)z&Set up the environment for one requestz
wsgi.inputzwsgi.errorszwsgi.versionz
wsgi.run_oncezwsgi.url_schemezwsgi.multithreadzwsgi.multiprocessNzwsgi.file_wrapperr)�
os_environ�copyr%�add_cgi_vars�	get_stdin�
get_stderr�wsgi_version�
wsgi_run_once�
get_scheme�wsgi_multithread�wsgi_multiprocess�wsgi_file_wrapper�
origin_server�server_software�
setdefault)r6�envrrrr0�s





zBaseHandler.setup_environc
CsJz:|j�s|j�r8x|jD]}|j|�qW|j�Wd|j�XdS)a>Send any iterable data, then close self and the iterable

        Subclasses intended for use in asynchronous servers will
        want to redefine this method, such that it sets up callbacks
        in the event loop to iterate over the data, and to call
        'self.close()' once the response is finished.
        N)�result_is_file�sendfiler2�write�finish_contentr5)r6�datarrrr3�szBaseHandler.finish_responsecCs
t|j�S)z Return the URL scheme being used)rr%)r6rrrr?�szBaseHandler.get_schemec
CsJyt|j�}Wntttfk
r(YnX|dkrFt|j�|jd<dSdS)z@Compute Content-Length or switch to chunked encoding if possiblerzContent-LengthN)�lenr2�	TypeError�AttributeError�NotImplementedError�str�
bytes_sent�headers)r6Zblocksrrr�set_content_length�szBaseHandler.set_content_lengthcCsd|jkr|j�dS)zqMake any necessary header changes or defaults

        Subclasses can extend this to add other defaults.
        zContent-LengthN)rRrS)r6rrr�cleanup_headers�s
zBaseHandler.cleanup_headerscCs�|r2z$|jr&|d|d�j|d��Wdd}Xn|jdk	rDtd��||_|j|�|_|j|d�}t|�dksvtd��|dd	�j�s�td
��|d	dks�td��x:|D]2\}}|j|d
�}|j|d�}t	|�s�td��q�W|j
S)z4'start_response()' callable as specified by PEP 3333rr�NzHeaders already set!ZStatus�z$Status must be at least 4 characters�z(Status message must begin w/3-digit code� z+Status message must have a space after codezHeader namezHeader valuezHop-by-hop headers not allowed)�headers_sent�with_tracebackrR�AssertionError�status�
headers_class�_convert_string_typerL�isdigitrrI)r6r\rR�exc_info�name�valrrrr1�s$
zBaseHandler.start_responsecCs(t|�tkr|Stdj|t|����dS)zConvert/check value type.z!{0} must be of type str (got {1})N)�typerPr[�format�repr)r6�value�titlerrrr^�sz BaseHandler._convert_string_typecCs�|jrx|j�r�|jd|j|jfjd��d|jkrP|jdttj��jd��|j	r�d|jkr�|jd|j	jd��n|jd|jjd��dS)	z6Transmit version/status/date/server, via self._write()zHTTP/%s %s
z
iso-8859-1ZDatez
Date: %s
ZServerzServer: %s
zStatus: %s
N)
rC�client_is_modern�_write�http_versionr\r"rRrr
rD)r6rrr�
send_preamble�s
zBaseHandler.send_preamblecCsft|�tkstd��|js$td��n,|js>t|�|_|j�n|jt|�7_|j|�|j	�dS)z+'write()' callable as specified by PEP 3333z)write() argument must be a bytes instancezwrite() before start_response()N)
rc�bytesr[r\rYrLrQ�send_headersri�_flush)r6rKrrrrIs



zBaseHandler.writecCsdS)aPlatform-specific file transmission

        Override this method in subclasses to support platform-specific
        file transmission.  It is only called if the application's
        return iterable ('self.result') is an instance of
        'self.wsgi_file_wrapper'.

        This method should return a true value if it was able to actually
        transmit the wrapped file-like object using a platform-specific
        approach.  It should return a false value if normal iteration
        should be used instead.  An exception can be raised to indicate
        that transmission was attempted, but failed.

        NOTE: this method should call 'self.send_headers()' if
        'self.headers_sent' is false and it is going to attempt direct
        transmission of the file.
        Fr)r6rrrrHszBaseHandler.sendfilecCs"|js|jjdd�|j�ndS)z.Ensure headers and content have both been sentzContent-Length�0N)rYrRrErm)r6rrrrJ0s
zBaseHandler.finish_contentcCsFzt|jd�r|jj�Wdd|_|_|_|_d|_d|_XdS)z�Close the iterable (if needed) and reset all instance vars

        Subclasses may want to also drop the client connection.
        r5NrF)�hasattrr2r5rRr\r%rQrY)r6rrrr5:szBaseHandler.closecCs:|j�d|_|js|j�r6|j�|jt|j��dS)z1Transmit headers to the client, via self._write()TN)rTrYrCrhrkrirlrR)r6rrrrmGs
zBaseHandler.send_headerscCs|j}|dk	ot|j|�S)z@True if 'self.result' is an instance of 'self.wsgi_file_wrapper'N)rB�
isinstancer2)r6�wrapperrrrrGPszBaseHandler.result_is_filecCs|jdj�dkS)z,True if client can accept status and headersZSERVER_PROTOCOLzHTTP/0.9)r%�upper)r6rrrrhVszBaseHandler.client_is_moderncCsJz>ddlm}|j�}||d|d|d|j|�|j�Wdd}XdS)z�Log the 'exc_info' tuple in the server log

        Subclasses may override to retarget the output or change its format.
        r)�print_exceptionrrUN)�	tracebackrtr<�traceback_limit�flush)r6r`rt�stderrrrr�
log_exception[s
zBaseHandler.log_exceptioncCs2|jtj��|js.|j|j|j�|_|j�dS)z>Log current error, and send error output to client if possibleN)	ryr r`rY�error_outputr%r1r2r3)r6rrrr4kszBaseHandler.handle_errorcCs$||j|jdd�tj��|jgS)aZWSGI mini-app to create error output

        By default, this just uses the 'error_status', 'error_headers',
        and 'error_body' attributes to generate an output page.  It can
        be overridden in a subclass to dynamically generate diagnostics,
        choose an appropriate message for the user's preferred language, etc.

        Note, however, that it's not recommended from a security perspective to
        spit out diagnostics to any old user; ideally, you should have to do
        something special to enable diagnostic output, which is why we don't
        include any here!
        N)�error_status�
error_headersr r`�
error_body)r6r%r1rrrrzss
zBaseHandler.error_outputcCst�dS)aOverride in subclass to buffer data for send to client

        It's okay if this method actually transmits the data; BaseHandler
        just separates write and flush operations for greater efficiency
        when the underlying system actually has such a distinction.
        N)rO)r6rKrrrri�szBaseHandler._writecCst�dS)z�Override in subclass to force sending of recent '_write()' calls

        It's okay if this method is a no-op (i.e., if '_write()' actually
        sends the data.
        N)rO)r6rrrrn�szBaseHandler._flushcCst�dS)z4Override in subclass to return suitable 'wsgi.input'N)rO)r6rrrr;�szBaseHandler.get_stdincCst�dS)z5Override in subclass to return suitable 'wsgi.errors'N)rO)r6rrrr<�szBaseHandler.get_stderrcCst�dS)z>Override in subclass to insert CGI variables in 'self.environ'N)rO)r6rrrr:�szBaseHandler.add_cgi_vars)rr)r.r/)N)2�__name__�
__module__�__qualname__�__doc__r=r@rAr>rCrjrDrr8rrBrr]rvr{r|r}r\r2rYrRrQr7r0r3r?rSrTr1r^rkrIrHrJr5rmrGrhryr4rzrirnr;r<r:rrrrr^sV



		c@sBeZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)raqHandler that's just initialized with streams, environment, etc.

    This handler subclass is intended for synchronous HTTP/1.0 origin servers,
    and handles sending the entire response output, given the correct inputs.

    Usage::

        handler = SimpleHandler(
            inp,out,err,env, multithread=False, multiprocess=True
        )
        handler.run(app)TFcCs(||_||_||_||_||_||_dS)N)�stdin�stdoutrx�base_envr@rA)r6r�r�rxr%�multithread�multiprocessrrr�__init__�szSimpleHandler.__init__cCs|jS)N)r�)r6rrrr;�szSimpleHandler.get_stdincCs|jS)N)rx)r6rrrr<�szSimpleHandler.get_stderrcCs|jj|j�dS)N)r%�updater�)r6rrrr:�szSimpleHandler.add_cgi_varscCsb|jj|�}|dks |t|�kr$dSddlm}|dt�x"||d�}|sNP|jj|�}q<WdS)Nr)�warnz9SimpleHandler.stdout.write() should not do partial writes)r�rIrL�warningsr��DeprecationWarning)r6rKr2r�rrrri�szSimpleHandler._writecCs|jj�|jj|_dS)N)r�rwrn)r6rrrrn�s
zSimpleHandler._flushN)TF)
r~rr�r�r�r;r<r:rirnrrrrr�s
	
c@seZdZdZdZdS)r	a�CGI-like systems using input/output/error streams and environ mapping

    Usage::

        handler = BaseCGIHandler(inp,out,err,env)
        handler.run(app)

    This handler class is useful for gateway protocols like ReadyExec and
    FastCGI, that have usable input/output/error streams and an environment
    mapping.  It's also the base class for CGIHandler, which just uses
    sys.stdin, os.environ, and so on.

    The constructor also takes keyword arguments 'multithread' and
    'multiprocess' (defaulting to 'True' and 'False' respectively) to control
    the configuration sent to the application.  It sets 'origin_server' to
    False (to enable CGI-like output), and assumes that 'wsgi.run_once' is
    False.
    FN)r~rr�r�rCrrrrr	�sc@s eZdZdZdZiZdd�ZdS)r
a�CGI-based invocation via sys.stdin/stdout/stderr and os.environ

    Usage::

        CGIHandler().run(app)

    The difference between this class and BaseCGIHandler is that it always
    uses 'wsgi.run_once' of 'True', 'wsgi.multithread' of 'False', and
    'wsgi.multiprocess' of 'True'.  It does not take any initialization
    parameters, but always uses 'sys.stdin', 'os.environ', and friends.

    If you need to override any of these parameters, use BaseCGIHandler
    instead.
    Tc	Cs(tj|tjjtjjtjt�ddd�dS)NFT)r�r�)r	r�r r��bufferr�rxr)r6rrrr�szCGIHandler.__init__N)r~rr�r�r>r8r�rrrrr
�sc@s eZdZdZdZiZdd�ZdS)raCGI-based invocation with workaround for IIS path bug

    This handler should be used in preference to CGIHandler when deploying on
    Microsoft IIS without having set the config allowPathInfo option (IIS>=7)
    or metabase allowPathInfoForScriptMappings (IIS<7).
    Tc	Csjt�}|jdd�}|jdd�}|dj|d�rD|t|�d�|d<tj|tjjtj	jtj
|ddd�dS)Nrrr�/FT)r�r�)rr(rrLr	r�r r�r�r�rx)r6r%�pathZscriptrrrr�$szIISCGIHandler.__init__N)r~rr�r�r>r8r�rrrrrs)r��utilrrrrRrr r$r
�__all__rrr�__contains__rrrrrr	r
rrrrr�<module>s*
<H2__pycache__/simple_server.cpython-36.pyc000064400000012113150327211600014254 0ustar003


 \�
@s dZddlmZmZddlZddlZddlmZddl	m
Z
dZddd	d
gZdeZ
e
�dejj�dZe
d
eZGdd�de�ZGdd�de�ZGdd�de�Zdd	�Zeefdd
�Zedk�redde��BZejj�Zededdedd�ddlZejd�ej�WdQRXdS)a!BaseHTTPServer that implements the Python WSGI protocol (PEP 3333)

This is both an example of how WSGI can be implemented, and a basis for running
simple web applications on a local machine, such as might be done when testing
or debugging an application.  It has not been reviewed for security issues,
however, and we strongly recommend that you use a "real" web server for
production use.

For example usage, see the 'if __name__=="__main__"' block at the end of the
module.  See also the BaseHTTPServer module docs for other API information.
�)�BaseHTTPRequestHandler�
HTTPServerN)�
SimpleHandler)�python_implementationz0.2�
WSGIServer�WSGIRequestHandler�demo_app�make_serverzWSGIServer/�/� c@seZdZeZdd�ZdS)�
ServerHandlercCs4z"|jj|jjdd�d|j�Wdtj|�XdS)Nr�r)�request_handlerZlog_requestZstatus�splitZ
bytes_sentr�close)�self�r�-/usr/lib64/python3.6/wsgiref/simple_server.pyr szServerHandler.closeN)�__name__�
__module__�__qualname__�software_versionZserver_softwarerrrrrrsrc@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)rz7BaseHTTPServer that implements the Python WSGI protocolNcCstj|�|j�dS)z.Override server_bind to store the server name.N)r�server_bind�
setup_environ)rrrrr0s
zWSGIServer.server_bindcCsFi}|_|j|d<d|d<t|j�|d<d|d<d|d<d|d<dS)	NZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PORT��REMOTE_HOST�CONTENT_LENGTHZSCRIPT_NAME)�base_environZserver_name�strZserver_port)r�envrrrr5s

zWSGIServer.setup_environcCs|jS)N)�application)rrrr�get_app?szWSGIServer.get_appcCs
||_dS)N)r )rr rrr�set_appBszWSGIServer.set_app)	rrr�__doc__r rrr!r"rrrrr*s
c@s,eZdZdeZdd�Zdd�Zdd�ZdS)	rzWSGIServer/cCsT|jjj�}|j|d<|j|d<|j|d<d|jkrH|jjdd�\}}n|jd}}tj	j
|d�|d<||d	<|j�}||jd
kr�||d<|jd
|d<|j
jd
�dkr�|j
j�|d<n|j
d
|d<|j
jd�}|r�||d<xn|j
j�D]`\}}|jdd�j�}|j�}||k�rq�d||k�r@|d|d|7<q�||d|<q�W|S)NZSERVER_PROTOCOLZSERVER_SOFTWAREZREQUEST_METHOD�?r
rz
iso-8859-1Z	PATH_INFOZQUERY_STRINGrrZREMOTE_ADDRzcontent-typeZCONTENT_TYPEzcontent-lengthr�-�_ZHTTP_�,)�serverr�copy�request_version�server_version�command�pathr�urllib�parseZunquoteZaddress_stringZclient_addressZheaders�getZget_content_type�items�replace�upper�strip)rrr-Zquery�hostZlength�k�vrrr�get_environKs8




zWSGIRequestHandler.get_environcCstjS)N)�sys�stderr)rrrr�
get_stderrpszWSGIRequestHandler.get_stderrcCs||jjd�|_t|j�dkr<d|_d|_d|_|jd�dS|j�sHdSt	|j|j
|j�|j��}||_
|j|jj��dS)zHandle a single HTTP requestiiri�N)Zrfile�readlineZraw_requestline�lenZrequestliner*r,Z
send_errorZ
parse_requestrZwfiler;r8rZrunr(r!)rZhandlerrrr�handless
zWSGIRequestHandler.handleN)rrr�__version__r+r8r;r>rrrrrGs%cCsvddlm}|�}td|d�t|d�t|j��}x$|D]\}}t|dt|�|d�q:W|dd
g�|j�jd	�gS)Nr)�StringIOzHello world!)�file�=z200 OK�Content-Type�text/plain; charset=utf-8zutf-8)rCrD)�ior@�print�sortedr1�repr�getvalue�encode)�environZstart_responser@�stdout�hr6r7rrrr�s
cCs|||f|�}|j|�|S)zACreate a new WSGI server listening on `host` and `port` for `app`)r")r5�portZappZserver_classZ
handler_classr(rrrr	�s
�__main__ri@zServing HTTP onrNr
z...zhttp://localhost:8000/xyz?abc) r#Zhttp.serverrrr9Zurllib.parser.Zwsgiref.handlersr�platformrr?�__all__r+�versionr�sys_versionrrrrrr	rZhttpdZsocketZgetsocknameZsarFZ
webbrowser�openZhandle_requestrrrr�<module>s,B



__pycache__/handlers.cpython-36.opt-2.pyc000064400000024042150327211600014141 0ustar003


 \	R�
@s�ddlmZmZmZddlmZddlZddlZddlZddddd	d
gZ	ddd
ddddgZ
dddddddddddddg
Zdd�Zd d!d"d#d$d%d&d'd(d)h
j
Zd*d+�Zd,d
�ZGd-d�d�ZGd.d�de�ZGd/d�de�ZGd0d�de�ZGd1d	�d	e�ZdS)2�)�FileWrapper�guess_scheme�
is_hop_by_hop)�Headers�N�BaseHandler�
SimpleHandler�BaseCGIHandler�
CGIHandler�
IISCGIHandler�read_environZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc
	Cs:tj|�\	}}}}}}}}}	dt||t|||||fS)Nz#%s, %02d %3s %4d %02d:%02d:%02d GMT)�timeZgmtime�_weekdayname�
_monthname)
Z	timestampZyearZmonthZdayZhhZmmZssZwd�y�z�r�(/usr/lib64/python3.6/wsgiref/handlers.py�format_date_timesr�SCRIPT_NAME�	PATH_INFOZQUERY_STRINGZREQUEST_METHODZ	AUTH_TYPEZCONTENT_TYPEZCONTENT_LENGTHZHTTPSZREMOTE_USERZREMOTE_IDENTcCs6t|�p4|jd�p4|jd�p4|jd�o4t|dd��S)NZHTTP_ZSSL_Z	REDIRECT_�	)�_is_request�
startswith�_needs_transcode)�krrrrsrcCs�tj�}d}ydjd|�Wntk
r4d}YnXi}x�tjj�D]�\}}t|�r�tjdkr�tjj	dd�j
�}|jd�r�|jd�jd�}q�|jd	�r�q�|jd
�r�d|kr�|jd�jd�}q�|j|d�jd�}n|j||�jd�}|||<qFW|S)N�surrogateescape�zutf-8�replaceZwin32�SERVER_SOFTWAREzmicrosoft-iis/z
iso-8859-1zapache/zsimplehttp/zpython/3)
�sys�getfilesystemencoding�encode�LookupError�os�environ�itemsr�platform�get�lowerr�decode)�enc�escr%r�vZsoftwarerrrr"s,

	


c@seZdZd;ZdZdZdZdZdZdZ	e
�ZeZ
eZdZdZd<gZd
ZdZZdZdZdZdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zd=dd�Zdd�Z dd�Z!dd�Z"dd �Z#d!d"�Z$d#d$�Z%d%d&�Z&d'd(�Z'd)d*�Z(d+d,�Z)d-d.�Z*d/d0�Z+d1d2�Z,d3d4�Z-d5d6�Z.d7d8�Z/d9d:�Z0dS)>rrrTFz1.0Nz500 Internal Server Error�Content-Type�
text/plains;A server error occurred.  Please contact the administrator.cCsZy$|j�||j|j�|_|j�Wn0y|j�Wn|j��YnXYnXdS)N)�
setup_environr%�start_response�result�finish_response�handle_error�close)�selfZapplicationrrr�run�szBaseHandler.runcCs�|jj�}|_|j�|j�|d<|j�|d<|j|d<|j|d<|j�|d<|j	|d<|j
|d<|jdk	rx|j|d<|jr�|j
r�|jd	|j
�dS)
Nz
wsgi.inputzwsgi.errorszwsgi.versionz
wsgi.run_oncezwsgi.url_schemezwsgi.multithreadzwsgi.multiprocesszwsgi.file_wrapperr)�
os_environ�copyr%�add_cgi_vars�	get_stdin�
get_stderr�wsgi_version�
wsgi_run_once�
get_scheme�wsgi_multithread�wsgi_multiprocess�wsgi_file_wrapper�
origin_server�server_software�
setdefault)r6�envrrrr0�s





zBaseHandler.setup_environc
CsJz:|j�s|j�r8x|jD]}|j|�qW|j�Wd|j�XdS)N)�result_is_file�sendfiler2�write�finish_contentr5)r6�datarrrr3�szBaseHandler.finish_responsecCs
t|j�S)N)rr%)r6rrrr?�szBaseHandler.get_schemec
CsJyt|j�}Wntttfk
r(YnX|dkrFt|j�|jd<dSdS)NrzContent-Length)�lenr2�	TypeError�AttributeError�NotImplementedError�str�
bytes_sent�headers)r6Zblocksrrr�set_content_length�szBaseHandler.set_content_lengthcCsd|jkr|j�dS)NzContent-Length)rRrS)r6rrr�cleanup_headers�s
zBaseHandler.cleanup_headerscCsh|r2z$|jr&|d|d�j|d��Wdd}Xn|jdk	rDtd��||_|j|�|_|j|d�}|jS)Nrr�zHeaders already set!ZStatus)�headers_sent�with_tracebackrR�AssertionError�status�
headers_class�_convert_string_typerI)r6rYrR�exc_inforrrr1�s
zBaseHandler.start_responsecCs(t|�tkr|Stdj|t|����dS)Nz!{0} must be of type str (got {1}))�typerPrX�format�repr)r6�value�titlerrrr[�sz BaseHandler._convert_string_typecCs�|jrx|j�r�|jd|j|jfjd��d|jkrP|jdttj��jd��|j	r�d|jkr�|jd|j	jd��n|jd|jjd��dS)NzHTTP/%s %s
z
iso-8859-1ZDatez
Date: %s
ZServerzServer: %s
zStatus: %s
)
rC�client_is_modern�_write�http_versionrYr"rRrr
rD)r6rrr�
send_preamble�s
zBaseHandler.send_preamblecCsR|jstd��n,|js*t|�|_|j�n|jt|�7_|j|�|j�dS)Nzwrite() before start_response())rYrXrVrLrQ�send_headersrc�_flush)r6rKrrrrIs



zBaseHandler.writecCsdS)NFr)r6rrrrHszBaseHandler.sendfilecCs"|js|jjdd�|j�ndS)NzContent-Length�0)rVrRrErf)r6rrrrJ0s
zBaseHandler.finish_contentcCsFzt|jd�r|jj�Wdd|_|_|_|_d|_d|_XdS)Nr5rF)�hasattrr2r5rRrYr%rQrV)r6rrrr5:szBaseHandler.closecCs:|j�d|_|js|j�r6|j�|jt|j��dS)NT)rTrVrCrbrerc�bytesrR)r6rrrrfGs
zBaseHandler.send_headerscCs|j}|dk	ot|j|�S)N)rB�
isinstancer2)r6�wrapperrrrrGPszBaseHandler.result_is_filecCs|jdj�dkS)NZSERVER_PROTOCOLzHTTP/0.9)r%�upper)r6rrrrbVszBaseHandler.client_is_moderncCsJz>ddlm}|j�}||d|d|d|j|�|j�Wdd}XdS)Nr)�print_exceptionrrU)�	tracebackrnr<�traceback_limit�flush)r6r\rn�stderrrrr�
log_exception[s
zBaseHandler.log_exceptioncCs2|jtj��|js.|j|j|j�|_|j�dS)N)	rsr r\rV�error_outputr%r1r2r3)r6rrrr4kszBaseHandler.handle_errorcCs$||j|jdd�tj��|jgS)N)�error_status�
error_headersr r\�
error_body)r6r%r1rrrrtss
zBaseHandler.error_outputcCst�dS)N)rO)r6rKrrrrc�szBaseHandler._writecCst�dS)N)rO)r6rrrrg�szBaseHandler._flushcCst�dS)N)rO)r6rrrr;�szBaseHandler.get_stdincCst�dS)N)rO)r6rrrr<�szBaseHandler.get_stderrcCst�dS)N)rO)r6rrrr:�szBaseHandler.add_cgi_vars)rr)r.r/)N)1�__name__�
__module__�__qualname__r=r@rAr>rCrdrDrr8rrBrrZrprurvrwrYr2rVrRrQr7r0r3r?rSrTr1r[rerIrHrJr5rfrGrbrsr4rtrcrgr;r<r:rrrrr^sT



		c@s>eZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�ZdS)rTFcCs(||_||_||_||_||_||_dS)N)�stdin�stdoutrr�base_envr@rA)r6r{r|rrr%�multithread�multiprocessrrr�__init__�szSimpleHandler.__init__cCs|jS)N)r{)r6rrrr;�szSimpleHandler.get_stdincCs|jS)N)rr)r6rrrr<�szSimpleHandler.get_stderrcCs|jj|j�dS)N)r%�updater})r6rrrr:�szSimpleHandler.add_cgi_varscCsb|jj|�}|dks |t|�kr$dSddlm}|dt�x"||d�}|sNP|jj|�}q<WdS)Nr)�warnz9SimpleHandler.stdout.write() should not do partial writes)r|rIrL�warningsr��DeprecationWarning)r6rKr2r�rrrrc�szSimpleHandler._writecCs|jj�|jj|_dS)N)r|rqrg)r6rrrrg�s
zSimpleHandler._flushN)TF)	rxryrzr�r;r<r:rcrgrrrrr�s
	
c@seZdZdZdS)r	FN)rxryrzrCrrrrr	�sc@seZdZdZiZdd�ZdS)r
Tc	Cs(tj|tjjtjjtjt�ddd�dS)NFT)r~r)r	r�r r{�bufferr|rrr)r6rrrr�szCGIHandler.__init__N)rxryrzr>r8r�rrrrr
�sc@seZdZdZiZdd�ZdS)rTc	Csjt�}|jdd�}|jdd�}|dj|d�rD|t|�d�|d<tj|tjjtj	jtj
|ddd�dS)Nrrr�/FT)r~r)rr(rrLr	r�r r{r�r|rr)r6r%�pathZscriptrrrr�$szIISCGIHandler.__init__N)rxryrzr>r8r�rrrrrs)�utilrrrrRrr r$r
�__all__rrr�__contains__rrrrrr	r
rrrrr�<module>s(
<H2__pycache__/simple_server.cpython-36.opt-2.pyc000064400000010502150327211600015214 0ustar003


 \�
@sddlmZmZddlZddlZddlmZddlm	Z	dZ
dddd	gZd
e
Ze	�dej
j�dZedeZGd
d�de�ZGdd�de�ZGdd�de�Zdd�Zeefdd	�Zedk�redde��BZejj�Zededdedd�ddlZejd�ej�WdQRXdS)�)�BaseHTTPRequestHandler�
HTTPServerN)�
SimpleHandler)�python_implementationz0.2�
WSGIServer�WSGIRequestHandler�demo_app�make_serverzWSGIServer/�/� c@seZdZeZdd�ZdS)�
ServerHandlercCs4z"|jj|jjdd�d|j�Wdtj|�XdS)Nr�r)�request_handlerZlog_requestZstatus�splitZ
bytes_sentr�close)�self�r�-/usr/lib64/python3.6/wsgiref/simple_server.pyr szServerHandler.closeN)�__name__�
__module__�__qualname__�software_versionZserver_softwarerrrrrrsrc@s0eZdZdZdd�Zdd�Zdd�Zdd	�ZdS)
rNcCstj|�|j�dS)N)r�server_bind�
setup_environ)rrrrr0s
zWSGIServer.server_bindcCsFi}|_|j|d<d|d<t|j�|d<d|d<d|d<d|d<dS)	NZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PORT��REMOTE_HOST�CONTENT_LENGTHZSCRIPT_NAME)�base_environZserver_name�strZserver_port)r�envrrrr5s

zWSGIServer.setup_environcCs|jS)N)�application)rrrr�get_app?szWSGIServer.get_appcCs
||_dS)N)r )rr rrr�set_appBszWSGIServer.set_app)rrrr rrr!r"rrrrr*s

c@s,eZdZdeZdd�Zdd�Zdd�ZdS)	rzWSGIServer/cCsT|jjj�}|j|d<|j|d<|j|d<d|jkrH|jjdd�\}}n|jd}}tj	j
|d�|d<||d	<|j�}||jd
kr�||d<|jd
|d<|j
jd
�dkr�|j
j�|d<n|j
d
|d<|j
jd�}|r�||d<xn|j
j�D]`\}}|jdd�j�}|j�}||k�rq�d||k�r@|d|d|7<q�||d|<q�W|S)NZSERVER_PROTOCOLZSERVER_SOFTWAREZREQUEST_METHOD�?r
rz
iso-8859-1Z	PATH_INFOZQUERY_STRINGrrZREMOTE_ADDRzcontent-typeZCONTENT_TYPEzcontent-lengthr�-�_ZHTTP_�,)�serverr�copy�request_version�server_version�command�pathr�urllib�parseZunquoteZaddress_stringZclient_addressZheaders�getZget_content_type�items�replace�upper�strip)rrr,Zquery�hostZlength�k�vrrr�get_environKs8




zWSGIRequestHandler.get_environcCstjS)N)�sys�stderr)rrrr�
get_stderrpszWSGIRequestHandler.get_stderrcCs||jjd�|_t|j�dkr<d|_d|_d|_|jd�dS|j�sHdSt	|j|j
|j�|j��}||_
|j|jj��dS)Niiri�)Zrfile�readlineZraw_requestline�lenZrequestliner)r+Z
send_errorZ
parse_requestrZwfiler:r7rZrunr'r!)rZhandlerrrr�handless
zWSGIRequestHandler.handleN)rrr�__version__r*r7r:r=rrrrrGs%cCsvddlm}|�}td|d�t|d�t|j��}x$|D]\}}t|dt|�|d�q:W|dd
g�|j�jd	�gS)Nr)�StringIOzHello world!)�file�=z200 OK�Content-Type�text/plain; charset=utf-8zutf-8)rBrC)�ior?�print�sortedr0�repr�getvalue�encode)�environZstart_responser?�stdout�hr5r6rrrr�s
cCs|||f|�}|j|�|S)N)r")r4�portZappZserver_classZ
handler_classr'rrrr	�s
�__main__ri@zServing HTTP onrMr
z...zhttp://localhost:8000/xyz?abc)Zhttp.serverrrr8Zurllib.parser-Zwsgiref.handlersr�platformrr>�__all__r*�versionr�sys_versionrrrrrr	rZhttpdZsocketZgetsocknameZsarEZ
webbrowser�openZhandle_requestrrrr�<module>
s*B



__pycache__/simple_server.cpython-36.opt-1.pyc000064400000012113150327211600015213 0ustar003


 \�
@s dZddlmZmZddlZddlZddlmZddl	m
Z
dZddd	d
gZdeZ
e
�dejj�dZe
d
eZGdd�de�ZGdd�de�ZGdd�de�Zdd	�Zeefdd
�Zedk�redde��BZejj�Zededdedd�ddlZejd�ej�WdQRXdS)a!BaseHTTPServer that implements the Python WSGI protocol (PEP 3333)

This is both an example of how WSGI can be implemented, and a basis for running
simple web applications on a local machine, such as might be done when testing
or debugging an application.  It has not been reviewed for security issues,
however, and we strongly recommend that you use a "real" web server for
production use.

For example usage, see the 'if __name__=="__main__"' block at the end of the
module.  See also the BaseHTTPServer module docs for other API information.
�)�BaseHTTPRequestHandler�
HTTPServerN)�
SimpleHandler)�python_implementationz0.2�
WSGIServer�WSGIRequestHandler�demo_app�make_serverzWSGIServer/�/� c@seZdZeZdd�ZdS)�
ServerHandlercCs4z"|jj|jjdd�d|j�Wdtj|�XdS)Nr�r)�request_handlerZlog_requestZstatus�splitZ
bytes_sentr�close)�self�r�-/usr/lib64/python3.6/wsgiref/simple_server.pyr szServerHandler.closeN)�__name__�
__module__�__qualname__�software_versionZserver_softwarerrrrrrsrc@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)rz7BaseHTTPServer that implements the Python WSGI protocolNcCstj|�|j�dS)z.Override server_bind to store the server name.N)r�server_bind�
setup_environ)rrrrr0s
zWSGIServer.server_bindcCsFi}|_|j|d<d|d<t|j�|d<d|d<d|d<d|d<dS)	NZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PORT��REMOTE_HOST�CONTENT_LENGTHZSCRIPT_NAME)�base_environZserver_name�strZserver_port)r�envrrrr5s

zWSGIServer.setup_environcCs|jS)N)�application)rrrr�get_app?szWSGIServer.get_appcCs
||_dS)N)r )rr rrr�set_appBszWSGIServer.set_app)	rrr�__doc__r rrr!r"rrrrr*s
c@s,eZdZdeZdd�Zdd�Zdd�ZdS)	rzWSGIServer/cCsT|jjj�}|j|d<|j|d<|j|d<d|jkrH|jjdd�\}}n|jd}}tj	j
|d�|d<||d	<|j�}||jd
kr�||d<|jd
|d<|j
jd
�dkr�|j
j�|d<n|j
d
|d<|j
jd�}|r�||d<xn|j
j�D]`\}}|jdd�j�}|j�}||k�rq�d||k�r@|d|d|7<q�||d|<q�W|S)NZSERVER_PROTOCOLZSERVER_SOFTWAREZREQUEST_METHOD�?r
rz
iso-8859-1Z	PATH_INFOZQUERY_STRINGrrZREMOTE_ADDRzcontent-typeZCONTENT_TYPEzcontent-lengthr�-�_ZHTTP_�,)�serverr�copy�request_version�server_version�command�pathr�urllib�parseZunquoteZaddress_stringZclient_addressZheaders�getZget_content_type�items�replace�upper�strip)rrr-Zquery�hostZlength�k�vrrr�get_environKs8




zWSGIRequestHandler.get_environcCstjS)N)�sys�stderr)rrrr�
get_stderrpszWSGIRequestHandler.get_stderrcCs||jjd�|_t|j�dkr<d|_d|_d|_|jd�dS|j�sHdSt	|j|j
|j�|j��}||_
|j|jj��dS)zHandle a single HTTP requestiiri�N)Zrfile�readlineZraw_requestline�lenZrequestliner*r,Z
send_errorZ
parse_requestrZwfiler;r8rZrunr(r!)rZhandlerrrr�handless
zWSGIRequestHandler.handleN)rrr�__version__r+r8r;r>rrrrrGs%cCsvddlm}|�}td|d�t|d�t|j��}x$|D]\}}t|dt|�|d�q:W|dd
g�|j�jd	�gS)Nr)�StringIOzHello world!)�file�=z200 OK�Content-Type�text/plain; charset=utf-8zutf-8)rCrD)�ior@�print�sortedr1�repr�getvalue�encode)�environZstart_responser@�stdout�hr6r7rrrr�s
cCs|||f|�}|j|�|S)zACreate a new WSGI server listening on `host` and `port` for `app`)r")r5�portZappZserver_classZ
handler_classr(rrrr	�s
�__main__ri@zServing HTTP onrNr
z...zhttp://localhost:8000/xyz?abc) r#Zhttp.serverrrr9Zurllib.parser.Zwsgiref.handlersr�platformrr?�__all__r+�versionr�sys_versionrrrrrr	rZhttpdZsocketZgetsocknameZsarFZ
webbrowser�openZhandle_requestrrrr�<module>s,B



__pycache__/handlers.cpython-36.opt-1.pyc000064400000036534150327211600014151 0ustar003


 \	R�
@sdZddlmZmZmZddlmZddlZddlZddl	Z	dddd	d
dgZ
dd
dddddgZdddddddddddddg
Zdd �Z
d!d"d#d$d%d&d'd(d)d*h
jZd+d,�Zd-d�ZGd.d�d�ZGd/d�de�ZGd0d�de�ZGd1d	�d	e�ZGd2d
�d
e�ZdS)3z/Base classes for server/gateway implementations�)�FileWrapper�guess_scheme�
is_hop_by_hop)�Headers�N�BaseHandler�
SimpleHandler�BaseCGIHandler�
CGIHandler�
IISCGIHandler�read_environZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc
	Cs:tj|�\	}}}}}}}}}	dt||t|||||fS)Nz#%s, %02d %3s %4d %02d:%02d:%02d GMT)�timeZgmtime�_weekdayname�
_monthname)
Z	timestampZyearZmonthZdayZhhZmmZssZwd�y�z�r�(/usr/lib64/python3.6/wsgiref/handlers.py�format_date_timesr�SCRIPT_NAME�	PATH_INFOZQUERY_STRINGZREQUEST_METHODZ	AUTH_TYPEZCONTENT_TYPEZCONTENT_LENGTHZHTTPSZREMOTE_USERZREMOTE_IDENTcCs6t|�p4|jd�p4|jd�p4|jd�o4t|dd��S)NZHTTP_ZSSL_Z	REDIRECT_�	)�_is_request�
startswith�_needs_transcode)�krrrrsrcCs�tj�}d}ydjd|�Wntk
r4d}YnXi}x�tjj�D]�\}}t|�r�tjdkr�tjj	dd�j
�}|jd�r�|jd�jd�}q�|jd	�r�q�|jd
�r�d|kr�|jd�jd�}q�|j|d�jd�}n|j||�jd�}|||<qFW|S)z'Read environment, fixing HTTP variables�surrogateescape�zutf-8�replaceZwin32�SERVER_SOFTWAREzmicrosoft-iis/z
iso-8859-1zapache/zsimplehttp/zpython/3)
�sys�getfilesystemencoding�encode�LookupError�os�environ�itemsr�platform�get�lowerr�decode)�enc�escr%r�vZsoftwarerrrr"s,

	


c@s"eZdZdZd<ZdZdZdZdZdZ	dZ
e�Ze
ZeZdZdZd=gZdZdZZdZdZdZdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zd>dd�Z dd�Z!dd�Z"dd�Z#d d!�Z$d"d#�Z%d$d%�Z&d&d'�Z'd(d)�Z(d*d+�Z)d,d-�Z*d.d/�Z+d0d1�Z,d2d3�Z-d4d5�Z.d6d7�Z/d8d9�Z0d:d;�Z1dS)?rz+Manage the invocation of a WSGI applicationrrTFz1.0Nz500 Internal Server Error�Content-Type�
text/plains;A server error occurred.  Please contact the administrator.cCsZy$|j�||j|j�|_|j�Wn0y|j�Wn|j��YnXYnXdS)zInvoke the applicationN)�
setup_environr%�start_response�result�finish_response�handle_error�close)�selfZapplicationrrr�run�szBaseHandler.runcCs�|jj�}|_|j�|j�|d<|j�|d<|j|d<|j|d<|j�|d<|j	|d<|j
|d<|jdk	rx|j|d	<|jr�|j
r�|jd
|j
�dS)z&Set up the environment for one requestz
wsgi.inputzwsgi.errorszwsgi.versionz
wsgi.run_oncezwsgi.url_schemezwsgi.multithreadzwsgi.multiprocessNzwsgi.file_wrapperr)�
os_environ�copyr%�add_cgi_vars�	get_stdin�
get_stderr�wsgi_version�
wsgi_run_once�
get_scheme�wsgi_multithread�wsgi_multiprocess�wsgi_file_wrapper�
origin_server�server_software�
setdefault)r6�envrrrr0�s





zBaseHandler.setup_environc
CsJz:|j�s|j�r8x|jD]}|j|�qW|j�Wd|j�XdS)a>Send any iterable data, then close self and the iterable

        Subclasses intended for use in asynchronous servers will
        want to redefine this method, such that it sets up callbacks
        in the event loop to iterate over the data, and to call
        'self.close()' once the response is finished.
        N)�result_is_file�sendfiler2�write�finish_contentr5)r6�datarrrr3�szBaseHandler.finish_responsecCs
t|j�S)z Return the URL scheme being used)rr%)r6rrrr?�szBaseHandler.get_schemec
CsJyt|j�}Wntttfk
r(YnX|dkrFt|j�|jd<dSdS)z@Compute Content-Length or switch to chunked encoding if possiblerzContent-LengthN)�lenr2�	TypeError�AttributeError�NotImplementedError�str�
bytes_sent�headers)r6Zblocksrrr�set_content_length�szBaseHandler.set_content_lengthcCsd|jkr|j�dS)zqMake any necessary header changes or defaults

        Subclasses can extend this to add other defaults.
        zContent-LengthN)rRrS)r6rrr�cleanup_headers�s
zBaseHandler.cleanup_headerscCsh|r2z$|jr&|d|d�j|d��Wdd}Xn|jdk	rDtd��||_|j|�|_|j|d�}|jS)z4'start_response()' callable as specified by PEP 3333rr�NzHeaders already set!ZStatus)�headers_sent�with_tracebackrR�AssertionError�status�
headers_class�_convert_string_typerI)r6rYrR�exc_inforrrr1�s
zBaseHandler.start_responsecCs(t|�tkr|Stdj|t|����dS)zConvert/check value type.z!{0} must be of type str (got {1})N)�typerPrX�format�repr)r6�value�titlerrrr[�sz BaseHandler._convert_string_typecCs�|jrx|j�r�|jd|j|jfjd��d|jkrP|jdttj��jd��|j	r�d|jkr�|jd|j	jd��n|jd|jjd��dS)	z6Transmit version/status/date/server, via self._write()zHTTP/%s %s
z
iso-8859-1ZDatez
Date: %s
ZServerzServer: %s
zStatus: %s
N)
rC�client_is_modern�_write�http_versionrYr"rRrr
rD)r6rrr�
send_preamble�s
zBaseHandler.send_preamblecCsR|jstd��n,|js*t|�|_|j�n|jt|�7_|j|�|j�dS)z+'write()' callable as specified by PEP 3333zwrite() before start_response()N)rYrXrVrLrQ�send_headersrc�_flush)r6rKrrrrIs



zBaseHandler.writecCsdS)aPlatform-specific file transmission

        Override this method in subclasses to support platform-specific
        file transmission.  It is only called if the application's
        return iterable ('self.result') is an instance of
        'self.wsgi_file_wrapper'.

        This method should return a true value if it was able to actually
        transmit the wrapped file-like object using a platform-specific
        approach.  It should return a false value if normal iteration
        should be used instead.  An exception can be raised to indicate
        that transmission was attempted, but failed.

        NOTE: this method should call 'self.send_headers()' if
        'self.headers_sent' is false and it is going to attempt direct
        transmission of the file.
        Fr)r6rrrrHszBaseHandler.sendfilecCs"|js|jjdd�|j�ndS)z.Ensure headers and content have both been sentzContent-Length�0N)rVrRrErf)r6rrrrJ0s
zBaseHandler.finish_contentcCsFzt|jd�r|jj�Wdd|_|_|_|_d|_d|_XdS)z�Close the iterable (if needed) and reset all instance vars

        Subclasses may want to also drop the client connection.
        r5NrF)�hasattrr2r5rRrYr%rQrV)r6rrrr5:szBaseHandler.closecCs:|j�d|_|js|j�r6|j�|jt|j��dS)z1Transmit headers to the client, via self._write()TN)rTrVrCrbrerc�bytesrR)r6rrrrfGs
zBaseHandler.send_headerscCs|j}|dk	ot|j|�S)z@True if 'self.result' is an instance of 'self.wsgi_file_wrapper'N)rB�
isinstancer2)r6�wrapperrrrrGPszBaseHandler.result_is_filecCs|jdj�dkS)z,True if client can accept status and headersZSERVER_PROTOCOLzHTTP/0.9)r%�upper)r6rrrrbVszBaseHandler.client_is_moderncCsJz>ddlm}|j�}||d|d|d|j|�|j�Wdd}XdS)z�Log the 'exc_info' tuple in the server log

        Subclasses may override to retarget the output or change its format.
        r)�print_exceptionrrUN)�	tracebackrnr<�traceback_limit�flush)r6r\rn�stderrrrr�
log_exception[s
zBaseHandler.log_exceptioncCs2|jtj��|js.|j|j|j�|_|j�dS)z>Log current error, and send error output to client if possibleN)	rsr r\rV�error_outputr%r1r2r3)r6rrrr4kszBaseHandler.handle_errorcCs$||j|jdd�tj��|jgS)aZWSGI mini-app to create error output

        By default, this just uses the 'error_status', 'error_headers',
        and 'error_body' attributes to generate an output page.  It can
        be overridden in a subclass to dynamically generate diagnostics,
        choose an appropriate message for the user's preferred language, etc.

        Note, however, that it's not recommended from a security perspective to
        spit out diagnostics to any old user; ideally, you should have to do
        something special to enable diagnostic output, which is why we don't
        include any here!
        N)�error_status�
error_headersr r\�
error_body)r6r%r1rrrrtss
zBaseHandler.error_outputcCst�dS)aOverride in subclass to buffer data for send to client

        It's okay if this method actually transmits the data; BaseHandler
        just separates write and flush operations for greater efficiency
        when the underlying system actually has such a distinction.
        N)rO)r6rKrrrrc�szBaseHandler._writecCst�dS)z�Override in subclass to force sending of recent '_write()' calls

        It's okay if this method is a no-op (i.e., if '_write()' actually
        sends the data.
        N)rO)r6rrrrg�szBaseHandler._flushcCst�dS)z4Override in subclass to return suitable 'wsgi.input'N)rO)r6rrrr;�szBaseHandler.get_stdincCst�dS)z5Override in subclass to return suitable 'wsgi.errors'N)rO)r6rrrr<�szBaseHandler.get_stderrcCst�dS)z>Override in subclass to insert CGI variables in 'self.environ'N)rO)r6rrrr:�szBaseHandler.add_cgi_vars)rr)r.r/)N)2�__name__�
__module__�__qualname__�__doc__r=r@rAr>rCrdrDrr8rrBrrZrprurvrwrYr2rVrRrQr7r0r3r?rSrTr1r[rerIrHrJr5rfrGrbrsr4rtrcrgr;r<r:rrrrr^sV



		c@sBeZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)raqHandler that's just initialized with streams, environment, etc.

    This handler subclass is intended for synchronous HTTP/1.0 origin servers,
    and handles sending the entire response output, given the correct inputs.

    Usage::

        handler = SimpleHandler(
            inp,out,err,env, multithread=False, multiprocess=True
        )
        handler.run(app)TFcCs(||_||_||_||_||_||_dS)N)�stdin�stdoutrr�base_envr@rA)r6r|r}rrr%�multithread�multiprocessrrr�__init__�szSimpleHandler.__init__cCs|jS)N)r|)r6rrrr;�szSimpleHandler.get_stdincCs|jS)N)rr)r6rrrr<�szSimpleHandler.get_stderrcCs|jj|j�dS)N)r%�updater~)r6rrrr:�szSimpleHandler.add_cgi_varscCsb|jj|�}|dks |t|�kr$dSddlm}|dt�x"||d�}|sNP|jj|�}q<WdS)Nr)�warnz9SimpleHandler.stdout.write() should not do partial writes)r}rIrL�warningsr��DeprecationWarning)r6rKr2r�rrrrc�szSimpleHandler._writecCs|jj�|jj|_dS)N)r}rqrg)r6rrrrg�s
zSimpleHandler._flushN)TF)
rxryrzr{r�r;r<r:rcrgrrrrr�s
	
c@seZdZdZdZdS)r	a�CGI-like systems using input/output/error streams and environ mapping

    Usage::

        handler = BaseCGIHandler(inp,out,err,env)
        handler.run(app)

    This handler class is useful for gateway protocols like ReadyExec and
    FastCGI, that have usable input/output/error streams and an environment
    mapping.  It's also the base class for CGIHandler, which just uses
    sys.stdin, os.environ, and so on.

    The constructor also takes keyword arguments 'multithread' and
    'multiprocess' (defaulting to 'True' and 'False' respectively) to control
    the configuration sent to the application.  It sets 'origin_server' to
    False (to enable CGI-like output), and assumes that 'wsgi.run_once' is
    False.
    FN)rxryrzr{rCrrrrr	�sc@s eZdZdZdZiZdd�ZdS)r
a�CGI-based invocation via sys.stdin/stdout/stderr and os.environ

    Usage::

        CGIHandler().run(app)

    The difference between this class and BaseCGIHandler is that it always
    uses 'wsgi.run_once' of 'True', 'wsgi.multithread' of 'False', and
    'wsgi.multiprocess' of 'True'.  It does not take any initialization
    parameters, but always uses 'sys.stdin', 'os.environ', and friends.

    If you need to override any of these parameters, use BaseCGIHandler
    instead.
    Tc	Cs(tj|tjjtjjtjt�ddd�dS)NFT)rr�)r	r�r r|�bufferr}rrr)r6rrrr�szCGIHandler.__init__N)rxryrzr{r>r8r�rrrrr
�sc@s eZdZdZdZiZdd�ZdS)raCGI-based invocation with workaround for IIS path bug

    This handler should be used in preference to CGIHandler when deploying on
    Microsoft IIS without having set the config allowPathInfo option (IIS>=7)
    or metabase allowPathInfoForScriptMappings (IIS<7).
    Tc	Csjt�}|jdd�}|jdd�}|dj|d�rD|t|�d�|d<tj|tjjtj	jtj
|ddd�dS)Nrrr�/FT)rr�)rr(rrLr	r�r r|r�r}rr)r6r%�pathZscriptrrrr�$szIISCGIHandler.__init__N)rxryrzr{r>r8r�rrrrrs)r{�utilrrrrRrr r$r
�__all__rrr�__contains__rrrrrr	r
rrrrr�<module>s*
<H2__pycache__/util.cpython-36.opt-1.pyc000064400000012112150327211600013310 0ustar003


 \�	@sxdZddlZddddddgZGd	d�d�Zd
d�Zdd�Zdd
d�Zdd�Zdd�Zddddddddd�j	Z
dd�ZdS)z$Miscellaneous WSGI-related Utilities�N�FileWrapper�guess_scheme�application_uri�request_uri�shift_path_info�setup_testing_defaultsc@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)
rz1Wrapper to convert file-like objects to iterables� cCs"||_||_t|d�r|j|_dS)N�close)�filelike�blksize�hasattrr	)�selfr
r�r�$/usr/lib64/python3.6/wsgiref/util.py�__init__s
zFileWrapper.__init__cCs|jj|j�}|r|St�dS)N)r
�readr�
IndexError)r
�key�datarrr�__getitem__szFileWrapper.__getitem__cCs|S)Nr)r
rrr�__iter__szFileWrapper.__iter__cCs|jj|j�}|r|St�dS)N)r
rr�
StopIteration)r
rrrr�__next__szFileWrapper.__next__N)r)�__name__�
__module__�__qualname__�__doc__rrrrrrrrrs

cCs|jd�dkrdSdSdS)	zMReturn a guess for whether 'wsgi.url_scheme' should be 'http' or 'https'
    ZHTTPS�yes�on�1�https�httpN)rrr)�get)�environrrrr#scCs�|dd}ddlm}|jd�r0||d7}nR||d7}|ddkrf|dd	kr�|d
|d7}n|ddkr�|d
|d7}|||jd�p�d
dd�7}|S)z@Return the application's base URI (no PATH_INFO or QUERY_STRING)zwsgi.url_schemez://r)�quote�	HTTP_HOST�SERVER_NAMEr �SERVER_PORT�443�:�80�SCRIPT_NAME�/�latin1)�encoding)�urllib.parser$r")r#�urlr$rrrr+s
TcCspt|�}ddlm}||jdd�ddd�}|jd�sF||d	d
�7}n||7}|rl|jd�rl|d|d7}|S)
zBReturn the full request URI, optionally including the query stringr)r$�	PATH_INFO�z/;=,r-)Zsafer.r+�NZQUERY_STRING�?)rr/r$r")r#Z
include_queryr0r$�	path_inforrrr?s
cCs�|jdd�}|sdS|jd�}dd�|dd
�D�|dd�<|d}|d=|jdd�}tj|d|�}|jd�r~|dd�}|r�|jd�r�|d7}||d<dj|�|d<|d	kr�d}|S)
aZShift a name from PATH_INFO to SCRIPT_NAME, returning it

    If there are no remaining path segments in PATH_INFO, return None.
    Note: 'environ' is modified in-place; use a copy if you need to keep
    the original PATH_INFO or SCRIPT_NAME.

    Note: when PATH_INFO is just a '/', this returns '' and appends a trailing
    '/' to SCRIPT_NAME, even though empty path segments are normally ignored,
    and SCRIPT_NAME doesn't normally end in a '/'.  This is intentional
    behavior, to ensure that an application can tell the difference between
    '/x' and '/x/' when traversing to objects.
    r1r2Nr,cSsg|]}|r|dkr|�qS)�.r)�.0�prrr�
<listcomp>^sz#shift_path_info.<locals>.<listcomp>r3r+r6���r:r:)r"�split�	posixpath�normpath�endswith�join)r#r5�
path_parts�nameZscript_namerrrrLs$


cCs�|jdd�|jdd�|jd|d�|jdd�d|kr\d	|kr\|jdd
�|jd	d�|jdd�|jdd�|jdd�|jdd�ddlm}m}|jd|��|jd|��|jdt|��|ddkr�|jdd�n|ddkr�|jdd�dS)a:Update 'environ' with trivial defaults for testing purposes

    This adds various parameters required for WSGI, including HTTP_HOST,
    SERVER_NAME, SERVER_PORT, REQUEST_METHOD, SCRIPT_NAME, PATH_INFO,
    and all of the wsgi.* variables.  It only supplies default values,
    and does not replace any existing settings for these variables.

    This routine is intended to make it easier for unit tests of WSGI
    servers and applications to set up dummy environments.  It should *not*
    be used by actual WSGI servers or applications, since the data is fake!
    r&z	127.0.0.1ZSERVER_PROTOCOLzHTTP/1.0r%ZREQUEST_METHODZGETr+r1r2r,zwsgi.versionr3rz
wsgi.run_oncezwsgi.multithreadzwsgi.multiprocess)�StringIO�BytesIOz
wsgi.inputzwsgi.errorszwsgi.url_schemer!r'r*r r(N)r3r)�
setdefault�iorBrCr)r#rBrCrrrrus&
r3)Z
connectionz
keep-alivezproxy-authenticatezproxy-authorizationZteZtrailersztransfer-encodingZupgradecCst|j��S)z?Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header)�_hoppish�lower)Zheader_namerrr�
is_hop_by_hop�srH)T)rr<�__all__rrrrrr�__contains__rFrHrrrr�<module>s

))
__pycache__/validate.cpython-36.opt-2.pyc000064400000025641150327211600014140 0ustar003


 \;;�@s�dgZddlZddlZddlZejd�Zejd�ZGdd�de�Zdd�Z	d	d
�Z
dd�ZGdd
�d
�ZGdd�d�Z
Gdd�d�ZGdd�d�ZGdd�d�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�ZdS)&�	validator�Nz^[a-zA-Z][a-zA-Z0-9\-_]*$z[\000-\037]c@seZdZdS)�WSGIWarningN)�__name__�
__module__�__qualname__�rr�(/usr/lib64/python3.6/wsgiref/validate.pyrysrcGs|st|��dS)N)�AssertionError)Zcond�argsrrr�assert_~srcCs(t|�tkr|Stdj|t|����dS)Nz!{0} must be of type str (got {1}))�type�strr	�format�repr)�value�titlerrr�check_string_type�srcs�fdd�}|S)Ncs�tt|�dkd�t|d�|\}�t|�g���fdd�}t|d�|d<t|d�|d<�||�}t|dk	oz|dkd	�t|�t|��S)
N�zTwo arguments requiredzNo keyword arguments allowedcs�tt|�dkpt|�dkd|f�t|d�|d}|d}t|�dkrV|d}nd}t|�t|�t||�t|��jd�t�|��S)Nr�zInvalid number of arguments: %szNo keyword arguments allowedr�)r�len�check_status�
check_headers�check_content_type�check_exc_info�append�WriteWrapper)r
�kw�status�headers�exc_info)�start_response�start_response_startedrr�start_response_wrapper�s


z;validator.<locals>.lint_app.<locals>.start_response_wrapperz
wsgi.inputzwsgi.errorsFz>The application must return an iterator, if only an empty list)rr�
check_environ�InputWrapper�ErrorWrapper�check_iterator�IteratorWrapper)r
r�environr#�iterator)�application)r!r"r�lint_app�s
zvalidator.<locals>.lint_appr)r+r,r)r+rr�s)c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)r%cCs
||_dS)N)�input)�self�
wsgi_inputrrr�__init__�szInputWrapper.__init__cGs0tt|�dk�|jj|�}tt|�tk�|S)Nr)rrr-�readr�bytes)r.r
�vrrrr1�szInputWrapper.readcGs0tt|�dk�|jj|�}tt|�tk�|S)Nr)rrr-�readlinerr2)r.r
r3rrrr4�szInputWrapper.readlinecGsNtt|�dk�|jj|�}tt|�tk�x|D]}tt|�tk�q2W|S)Nr)rrr-�	readlinesr�listr2)r.r
�lines�linerrrr5�s
zInputWrapper.readlinesccs x|j�}|sdS|VqWdS)N)r4)r.r8rrr�__iter__�s
zInputWrapper.__iter__cCstdd�dS)Nrz input.close() must not be called)r)r.rrr�close�szInputWrapper.closeN)	rrrr0r1r4r5r9r:rrrrr%�sr%c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r&cCs
||_dS)N)�errors)r.�wsgi_errorsrrrr0�szErrorWrapper.__init__cCs tt|�tk�|jj|�dS)N)rrr
r;�write)r.�srrrr=�szErrorWrapper.writecCs|jj�dS)N)r;�flush)r.rrrr?�szErrorWrapper.flushcCsx|D]}|j|�qWdS)N)r=)r.�seqr8rrr�
writelines�s
zErrorWrapper.writelinescCstdd�dS)Nrz!errors.close() must not be called)r)r.rrrr:�szErrorWrapper.closeN)rrrr0r=r?rAr:rrrrr&�s
r&c@seZdZdd�Zdd�ZdS)rcCs
||_dS)N)�writer)r.Zwsgi_writerrrrr0�szWriteWrapper.__init__cCstt|�tk�|j|�dS)N)rrr2rB)r.r>rrr�__call__�szWriteWrapper.__call__N)rrrr0rCrrrrr�src@seZdZdd�Zdd�ZdS)�PartialIteratorWrappercCs
||_dS)N)r*)r.�
wsgi_iteratorrrrr0szPartialIteratorWrapper.__init__cCst|jd�S)N)r(r*)r.rrrr9szPartialIteratorWrapper.__iter__N)rrrr0r9rrrrrD�srDc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r(cCs ||_t|�|_d|_||_dS)NF)�original_iterator�iterr*�closed�check_start_response)r.rErIrrrr0	s
zIteratorWrapper.__init__cCs|S)Nr)r.rrrr9szIteratorWrapper.__iter__cCsTt|jd�t|j�}t|�tk	r4tdd|f�|jdk	rPt|jd�d|_|S)NzIterator read after closedFz$Iterator yielded non-bytestring (%r)zjThe application returns and we started iterating over its body, but start_response has not yet been called)rrH�nextr*rr2rI)r.r3rrr�__next__s

zIteratorWrapper.__next__cCs d|_t|jd�r|jj�dS)NTr:)rH�hasattrrFr:)r.rrrr:szIteratorWrapper.closecCs"|jstjjd�t|jd�dS)Nz/Iterator garbage collected without being closed)rH�sys�stderrr=r)r.rrr�__del__#s
zIteratorWrapper.__del__N)rrrr0r9rKr:rOrrrrr(s
r(c	Cs�tt|�tkdt|�|f�x d,D]}t||kd|f�q$Wx*d-D]"}t||kd||dd�f�qFWd|kr�tjdt�xF|j�D]:}d|kr�q�tt||�tkd|t||�||f�q�Wtt|d�tkd|df�t|dd.kd|d�t	|d�t
|d�|dd/k�r<tjd!|dt�t|jd"��pX|d"jd#�d$|d"�t|jd%��p�|d%jd#�d&|d%�|jd'��r�tt
|d'�d(kd)|d'�|jd"��s�td%|kd*�t|jd"�d#kd+�dS)0Nz:Environment is not of the right type: %r (environment: %r)�REQUEST_METHOD�SERVER_NAME�SERVER_PORT�wsgi.version�
wsgi.input�wsgi.errors�wsgi.multithread�wsgi.multiprocess�
wsgi.run_oncez$Environment missing required key: %r�HTTP_CONTENT_TYPE�HTTP_CONTENT_LENGTHz8Environment should not have the key: %s (use %s instead)�ZQUERY_STRINGz�QUERY_STRING is not in the WSGI environment; the cgi module will use sys.argv when this variable is missing, so application errors are more likely�.z9Environmental variable %s is not a string: %r (value: %r)z#wsgi.version should be a tuple (%r)zwsgi.url_scheme�http�httpszwsgi.url_scheme unknown: %r�GET�HEAD�POST�OPTIONS�PATCH�PUT�DELETE�TRACEzUnknown REQUEST_METHOD: %rZSCRIPT_NAME�/z$SCRIPT_NAME doesn't start with /: %rZ	PATH_INFOz"PATH_INFO doesn't start with /: %rZCONTENT_LENGTHrzInvalid CONTENT_LENGTH: %rzgOne of SCRIPT_NAME or PATH_INFO are required (PATH_INFO should at least be '/' if SCRIPT_NAME is empty)zOSCRIPT_NAME cannot be '/'; it should instead be '', and PATH_INFO should be '/')	rPrQrRrSrTrUrVrWrX)rYrZ)r]r^)r_r`rarbrcrdrerf)rr�dict�warnings�warnr�keysr
�tuple�check_input�check_errors�get�
startswith�int)r)�keyrrrr$*s`

r$cCs*x$dD]}tt||�d||f�qWdS)Nr1r4r5r9z-wsgi.input (%r) doesn't have the attribute %s)r1r4r5r9)rrL)r/�attrrrrrmks

rmcCs*x$dD]}tt||�d||f�qWdS)Nr?r=rAz.wsgi.errors (%r) doesn't have the attribute %s)r?r=rA)rrL)r<rsrrrrnqs

rncCsvt|d�}|jdd�d}tt|�dkd|�t|�}t|dkd|�t|�dksb|dd	krrtjd
|t�dS)N�Statusrrrz)Status codes must be three characters: %r�dzStatus code is invalid: %r�� zjThe status string (%r) should be a three-digit integer followed by a single space and a status explanation)r�splitrrrqrirjr)rZstatus_codeZ
status_intrrrrws

rcCstt|�tkd|t|�f�i}x�|D]�}tt|�tkd|t|�f�tt|�dk�|\}}t|d�}t|d�}t|j�dkd|�d||j�<td|ko�d	|kd
|�ttj|�d|�t|j	d�o�|j	d
�d|�t
j|�r(tdd|t
j|�jd�f�q(WdS)Nz%Headers (%r) must be of type list: %rz1Individual headers (%r) must be of type tuple: %rrzHeader namezHeader valuerzyThe Status header cannot be used; it conflicts with CGI script, and HTTP status is not given through headers (value: %r).�
�:z,Header names may not contain ':' or '\n': %rzBad header name: %r�-�_z#Names may not end in '-' or '_': %rrz#Bad header value: %r (bad char: %r))rrr6rlrr�lower�	header_re�search�endswith�bad_header_value_re�group)rZheader_names�item�namerrrrr�s0





rcCs~t|d�}t|jdd�d�}d
}x@|D]8\}}t|d�}|j�dkr(||krRdStdd|�q(W||krztdd	|�dS)Nrtrr���0zHeader namezcontent-typezJContent-Type header found in a %s response, which must not return content.z,No Content-Type header found in headers (%s))r�r�)rrqrxr}r)rr�codeZNO_MESSAGE_BODYr�rrrrr�s

rcCs*t|dkpt|�tkd|t|�f�dS)Nz exc_info (%r) is not a tuple: %r)rrrl)r rrrr�srcCstt|ttf�d�dS)NzwYou should not return a string as your application iterator, instead return a single-item list containing a bytestring.)r�
isinstancer
r2)r*rrrr'�sr')�__all__�rerMri�compiler~r��Warningrrrrr%r&rrDr(r$rmrnrrrrr'rrrr�<module>os,

7#		#A__pycache__/headers.cpython-36.pyc000064400000017073150327211600013022 0ustar003


 \n�@s2dZddlZejd�Zd	dd�ZGdd�d�ZdS)
z�Manage HTTP Response Headers

Much of this module is red-handedly pilfered from email.message in the stdlib,
so portions are Copyright (C) 2001,2002 Python Software Foundation, and were
written by Barry Warsaw.
�Nz[ \(\)<>@,;:\\"/\[\]\?=]�cCsX|dk	rPt|�dkrP|s"tj|�rB|jdd�jdd�}d||fSd||fSn|SdS)	z~Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.
    Nr�\z\\�"z\"z%s="%s"z%s=%s)�len�	tspecials�search�replace)Zparam�valueZquote�r
�'/usr/lib64/python3.6/wsgiref/headers.py�_formatparam
src@s�eZdZdZd%dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zd&dd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�ZdS)'�Headersz,Manage a collection of HTTP response headersNcCsT|dk	r|ng}t|�tk	r$td��||_x$|D]\}}|j|�|j|�q0WdS)Nz+Headers must be a list of name/value tuples)�type�list�	TypeError�_headers�_convert_string_type)�selfZheaders�k�vr
r
r�__init__s
zHeaders.__init__cCs&t|�tkr|Stdjt|����dS)zConvert/check value type.z1Header names/values must be of type str (got {0})N)r�str�AssertionError�format�repr)rr	r
r
rr)szHeaders._convert_string_typecCs
t|j�S)z9Return the total number of headers, including duplicates.)rr)rr
r
r�__len__0szHeaders.__len__cCs&||=|jj|j|�|j|�f�dS)zSet the value of a header.N)r�appendr)r�name�valr
r
r�__setitem__4szHeaders.__setitem__cs0|j�j����fdd�|jD�|jdd�<dS)zyDelete all occurrences of a header, if present.

        Does *not* raise an exception if the header is missing.
        cs g|]}|dj��kr|�qS)r)�lower)�.0�kv)rr
r�
<listcomp>@sz'Headers.__delitem__.<locals>.<listcomp>N)rr r)rrr
)rr�__delitem__:szHeaders.__delitem__cCs
|j|�S)aHGet the first header value for 'name'

        Return None if the header is missing instead of raising an exception.

        Note that if the header appeared multiple times, the first exactly which
        occurrence gets returned is undefined.  Use getall() to get all
        the values matching a header field name.
        )�get)rrr
r
r�__getitem__Bs	zHeaders.__getitem__cCs|j|�dk	S)z/Return true if the message contains the header.N)r%)rrr
r
r�__contains__MszHeaders.__contains__cs"|j�j����fdd�|jD�S)aqReturn a list of all the values for the named field.

        These will be sorted in the order they appeared in the original header
        list or were added to this instance, and may contain duplicates.  Any
        fields deleted and re-inserted are always appended to the header list.
        If no fields exist with the given name, returns an empty list.
        cs$g|]}|dj��kr|d�qS)rr)r )r!r")rr
rr#[sz#Headers.get_all.<locals>.<listcomp>)rr r)rrr
)rr�get_allRszHeaders.get_allcCs6|j|j��}x"|jD]\}}|j�|kr|SqW|S)z:Get the first header value for 'name', or return 'default')rr r)rr�defaultrrr
r
rr%^s
zHeaders.getcCsdd�|jD�S)a*Return a list of all the header field names.

        These will be sorted in the order they appeared in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cSsg|]\}}|�qSr
r
)r!rrr
r
rr#osz Headers.keys.<locals>.<listcomp>)r)rr
r
r�keysgszHeaders.keyscCsdd�|jD�S)a!Return a list of all header values.

        These will be sorted in the order they appeared in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cSsg|]\}}|�qSr
r
)r!rrr
r
rr#ysz"Headers.values.<locals>.<listcomp>)r)rr
r
r�valuesqszHeaders.valuescCs|jdd�S)aGet all the header fields and values.

        These will be sorted in the order they were in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        N)r)rr
r
r�items{sz
Headers.itemscCsd|jj|jfS)Nz%s(%r))�	__class__�__name__r)rr
r
r�__repr__�szHeaders.__repr__cCsdjdd�|jD�ddg�S)zkstr() returns the formatted headers, complete with end line,
        suitable for direct HTTP transmission.z
cSsg|]}d|�qS)z%s: %sr
)r!r"r
r
rr#�sz#Headers.__str__.<locals>.<listcomp>�)�joinr)rr
r
r�__str__�szHeaders.__str__cCst|�jd�S)Nz
iso-8859-1)r�encode)rr
r
r�	__bytes__�szHeaders.__bytes__cCs:|j|�}|dkr2|jj|j|�|j|�f�|S|SdS)z�Return first matching header value for 'name', or 'value'

        If there is no header named 'name', add a new header with name 'name'
        and value 'value'.N)r%rrr)rrr	�resultr
r
r�
setdefault�s
zHeaders.setdefaultcKs�g}|dk	r |j|�}|j|�x\|j�D]P\}}|j|�}|dkrX|j|jdd��q*|j|�}|jt|jdd�|��q*W|jj|j|�dj|�f�dS)afExtended header setting.

        _name is the header field to add.  keyword arguments can be used to set
        additional parameters for the header field, with underscores converted
        to dashes.  Normally the parameter will be added as key="value" unless
        value is None, in which case only the key will be added.

        Example:

        h.add_header('content-disposition', 'attachment', filename='bud.gif')

        Note that unlike the corresponding 'email.message' method, this does
        *not* handle '(charset, language, value)' tuples: all values must be
        strings or None.
        N�_�-z; )rrr,rrrr1)r�_nameZ_valueZ_params�partsrrr
r
r�
add_header�s



zHeaders.add_header)N)N)r.�
__module__�__qualname__�__doc__rrrrr$r&r'r(r%r*r+r,r/r2r4r6r;r
r
r
rr
s$


	



r
)Nr)r>�re�compilerrr
r
r
r
r�<module>s

__pycache__/util.cpython-36.opt-2.pyc000064400000007045150327211600013322 0ustar003


 \�	@stddlZddddddgZGdd�d�Zd	d�Zd
d�Zddd�Zd
d�Zdd�Zddddddddd�jZ	dd�Z
dS)�N�FileWrapper�guess_scheme�application_uri�request_uri�shift_path_info�setup_testing_defaultsc@s.eZdZddd�Zdd�Zdd�Zdd	�Zd
S)r� cCs"||_||_t|d�r|j|_dS)N�close)�filelike�blksize�hasattrr	)�selfr
r�r�$/usr/lib64/python3.6/wsgiref/util.py�__init__s
zFileWrapper.__init__cCs|jj|j�}|r|St�dS)N)r
�readr�
IndexError)r
�key�datarrr�__getitem__szFileWrapper.__getitem__cCs|S)Nr)r
rrr�__iter__szFileWrapper.__iter__cCs|jj|j�}|r|St�dS)N)r
rr�
StopIteration)r
rrrr�__next__szFileWrapper.__next__N)r)�__name__�
__module__�__qualname__rrrrrrrrrs
cCs|jd�dkrdSdSdS)NZHTTPS�yes�on�1�https�http)rrr)�get)�environrrrr#scCs�|dd}ddlm}|jd�r0||d7}nR||d7}|ddkrf|dd	kr�|d
|d7}n|ddkr�|d
|d7}|||jd�p�d
dd�7}|S)Nzwsgi.url_schemez://r)�quote�	HTTP_HOST�SERVER_NAMEr�SERVER_PORT�443�:�80�SCRIPT_NAME�/�latin1)�encoding)�urllib.parser#r!)r"�urlr#rrrr+s
TcCspt|�}ddlm}||jdd�ddd�}|jd�sF||d	d�7}n||7}|rl|jd
�rl|d|d
7}|S)Nr)r#�	PATH_INFO�z/;=,r,)Zsafer-r*�ZQUERY_STRING�?)rr.r#r!)r"Z
include_queryr/r#�	path_inforrrr?s
cCs�|jdd�}|sdS|jd�}dd�|dd	�D�|dd
�<|d}|d=|jdd�}tj|d|�}|jd�r~|dd�}|r�|jd�r�|d7}||d<dj|�|d<|dkr�d}|S)Nr0r1r+cSsg|]}|r|dkr|�qS)�.r)�.0�prrr�
<listcomp>^sz#shift_path_info.<locals>.<listcomp>r2r*r5���r9r9)r!�split�	posixpath�normpath�endswith�join)r"r4�
path_parts�nameZscript_namerrrrLs$


cCs�|jdd�|jdd�|jd|d�|jdd�d|kr\d	|kr\|jdd
�|jd	d�|jdd�|jdd�|jdd�|jdd�ddlm}m}|jd|��|jd|��|jdt|��|ddkr�|jdd�n|ddkr�|jdd�dS)Nr%z	127.0.0.1ZSERVER_PROTOCOLzHTTP/1.0r$ZREQUEST_METHODZGETr*r0r1r+zwsgi.versionr2rz
wsgi.run_oncezwsgi.multithreadzwsgi.multiprocess)�StringIO�BytesIOz
wsgi.inputzwsgi.errorszwsgi.url_schemer r&r)rr')r2r)�
setdefault�iorArBr)r"rArBrrrrus&
r2)Z
connectionz
keep-alivezproxy-authenticatezproxy-authorizationZteZtrailersztransfer-encodingZupgradecCst|j��S)N)�_hoppish�lower)Zheader_namerrr�
is_hop_by_hop�srG)T)r;�__all__rrrrrr�__contains__rErGrrrr�<module>s

))
__pycache__/util.cpython-36.pyc000064400000012112150327211600012351 0ustar003


 \�	@sxdZddlZddddddgZGd	d�d�Zd
d�Zdd�Zdd
d�Zdd�Zdd�Zddddddddd�j	Z
dd�ZdS)z$Miscellaneous WSGI-related Utilities�N�FileWrapper�guess_scheme�application_uri�request_uri�shift_path_info�setup_testing_defaultsc@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)
rz1Wrapper to convert file-like objects to iterables� cCs"||_||_t|d�r|j|_dS)N�close)�filelike�blksize�hasattrr	)�selfr
r�r�$/usr/lib64/python3.6/wsgiref/util.py�__init__s
zFileWrapper.__init__cCs|jj|j�}|r|St�dS)N)r
�readr�
IndexError)r
�key�datarrr�__getitem__szFileWrapper.__getitem__cCs|S)Nr)r
rrr�__iter__szFileWrapper.__iter__cCs|jj|j�}|r|St�dS)N)r
rr�
StopIteration)r
rrrr�__next__szFileWrapper.__next__N)r)�__name__�
__module__�__qualname__�__doc__rrrrrrrrrs

cCs|jd�dkrdSdSdS)	zMReturn a guess for whether 'wsgi.url_scheme' should be 'http' or 'https'
    ZHTTPS�yes�on�1�https�httpN)rrr)�get)�environrrrr#scCs�|dd}ddlm}|jd�r0||d7}nR||d7}|ddkrf|dd	kr�|d
|d7}n|ddkr�|d
|d7}|||jd�p�d
dd�7}|S)z@Return the application's base URI (no PATH_INFO or QUERY_STRING)zwsgi.url_schemez://r)�quote�	HTTP_HOST�SERVER_NAMEr �SERVER_PORT�443�:�80�SCRIPT_NAME�/�latin1)�encoding)�urllib.parser$r")r#�urlr$rrrr+s
TcCspt|�}ddlm}||jdd�ddd�}|jd�sF||d	d
�7}n||7}|rl|jd�rl|d|d7}|S)
zBReturn the full request URI, optionally including the query stringr)r$�	PATH_INFO�z/;=,r-)Zsafer.r+�NZQUERY_STRING�?)rr/r$r")r#Z
include_queryr0r$�	path_inforrrr?s
cCs�|jdd�}|sdS|jd�}dd�|dd
�D�|dd�<|d}|d=|jdd�}tj|d|�}|jd�r~|dd�}|r�|jd�r�|d7}||d<dj|�|d<|d	kr�d}|S)
aZShift a name from PATH_INFO to SCRIPT_NAME, returning it

    If there are no remaining path segments in PATH_INFO, return None.
    Note: 'environ' is modified in-place; use a copy if you need to keep
    the original PATH_INFO or SCRIPT_NAME.

    Note: when PATH_INFO is just a '/', this returns '' and appends a trailing
    '/' to SCRIPT_NAME, even though empty path segments are normally ignored,
    and SCRIPT_NAME doesn't normally end in a '/'.  This is intentional
    behavior, to ensure that an application can tell the difference between
    '/x' and '/x/' when traversing to objects.
    r1r2Nr,cSsg|]}|r|dkr|�qS)�.r)�.0�prrr�
<listcomp>^sz#shift_path_info.<locals>.<listcomp>r3r+r6���r:r:)r"�split�	posixpath�normpath�endswith�join)r#r5�
path_parts�nameZscript_namerrrrLs$


cCs�|jdd�|jdd�|jd|d�|jdd�d|kr\d	|kr\|jdd
�|jd	d�|jdd�|jdd�|jdd�|jdd�ddlm}m}|jd|��|jd|��|jdt|��|ddkr�|jdd�n|ddkr�|jdd�dS)a:Update 'environ' with trivial defaults for testing purposes

    This adds various parameters required for WSGI, including HTTP_HOST,
    SERVER_NAME, SERVER_PORT, REQUEST_METHOD, SCRIPT_NAME, PATH_INFO,
    and all of the wsgi.* variables.  It only supplies default values,
    and does not replace any existing settings for these variables.

    This routine is intended to make it easier for unit tests of WSGI
    servers and applications to set up dummy environments.  It should *not*
    be used by actual WSGI servers or applications, since the data is fake!
    r&z	127.0.0.1ZSERVER_PROTOCOLzHTTP/1.0r%ZREQUEST_METHODZGETr+r1r2r,zwsgi.versionr3rz
wsgi.run_oncezwsgi.multithreadzwsgi.multiprocess)�StringIO�BytesIOz
wsgi.inputzwsgi.errorszwsgi.url_schemer!r'r*r r(N)r3r)�
setdefault�iorBrCr)r#rBrCrrrrus&
r3)Z
connectionz
keep-alivezproxy-authenticatezproxy-authorizationZteZtrailersztransfer-encodingZupgradecCst|j��S)z?Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header)�_hoppish�lower)Zheader_namerrr�
is_hop_by_hop�srH)T)rr<�__all__rrrrrr�__contains__rFrHrrrr�<module>s

))
__pycache__/headers.cpython-36.opt-1.pyc000064400000017002150327211600013751 0ustar003


 \n�@s2dZddlZejd�Zd	dd�ZGdd�d�ZdS)
z�Manage HTTP Response Headers

Much of this module is red-handedly pilfered from email.message in the stdlib,
so portions are Copyright (C) 2001,2002 Python Software Foundation, and were
written by Barry Warsaw.
�Nz[ \(\)<>@,;:\\"/\[\]\?=]�cCsX|dk	rPt|�dkrP|s"tj|�rB|jdd�jdd�}d||fSd||fSn|SdS)	z~Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.
    Nr�\z\\�"z\"z%s="%s"z%s=%s)�len�	tspecials�search�replace)Zparam�valueZquote�r
�'/usr/lib64/python3.6/wsgiref/headers.py�_formatparam
src@s�eZdZdZd%dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zd&dd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�ZdS)'�Headersz,Manage a collection of HTTP response headersNcCs.|dk	r|ng}t|�tk	r$td��||_dS)Nz+Headers must be a list of name/value tuples)�type�list�	TypeError�_headers)�selfZheadersr
r
r�__init__s
zHeaders.__init__cCs&t|�tkr|Stdjt|����dS)zConvert/check value type.z1Header names/values must be of type str (got {0})N)r�str�AssertionError�format�repr)rr	r
r
r�_convert_string_type)szHeaders._convert_string_typecCs
t|j�S)z9Return the total number of headers, including duplicates.)rr)rr
r
r�__len__0szHeaders.__len__cCs&||=|jj|j|�|j|�f�dS)zSet the value of a header.N)r�appendr)r�name�valr
r
r�__setitem__4szHeaders.__setitem__cs0|j�j����fdd�|jD�|jdd�<dS)zyDelete all occurrences of a header, if present.

        Does *not* raise an exception if the header is missing.
        cs g|]}|dj��kr|�qS)r)�lower)�.0�kv)rr
r�
<listcomp>@sz'Headers.__delitem__.<locals>.<listcomp>N)rrr)rrr
)rr�__delitem__:szHeaders.__delitem__cCs
|j|�S)aHGet the first header value for 'name'

        Return None if the header is missing instead of raising an exception.

        Note that if the header appeared multiple times, the first exactly which
        occurrence gets returned is undefined.  Use getall() to get all
        the values matching a header field name.
        )�get)rrr
r
r�__getitem__Bs	zHeaders.__getitem__cCs|j|�dk	S)z/Return true if the message contains the header.N)r#)rrr
r
r�__contains__MszHeaders.__contains__cs"|j�j����fdd�|jD�S)aqReturn a list of all the values for the named field.

        These will be sorted in the order they appeared in the original header
        list or were added to this instance, and may contain duplicates.  Any
        fields deleted and re-inserted are always appended to the header list.
        If no fields exist with the given name, returns an empty list.
        cs$g|]}|dj��kr|d�qS)rr)r)rr )rr
rr![sz#Headers.get_all.<locals>.<listcomp>)rrr)rrr
)rr�get_allRszHeaders.get_allcCs6|j|j��}x"|jD]\}}|j�|kr|SqW|S)z:Get the first header value for 'name', or return 'default')rrr)rr�default�k�vr
r
rr#^s
zHeaders.getcCsdd�|jD�S)a*Return a list of all the header field names.

        These will be sorted in the order they appeared in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cSsg|]\}}|�qSr
r
)rr(r)r
r
rr!osz Headers.keys.<locals>.<listcomp>)r)rr
r
r�keysgszHeaders.keyscCsdd�|jD�S)a!Return a list of all header values.

        These will be sorted in the order they appeared in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cSsg|]\}}|�qSr
r
)rr(r)r
r
rr!ysz"Headers.values.<locals>.<listcomp>)r)rr
r
r�valuesqszHeaders.valuescCs|jdd�S)aGet all the header fields and values.

        These will be sorted in the order they were in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        N)r)rr
r
r�items{sz
Headers.itemscCsd|jj|jfS)Nz%s(%r))�	__class__�__name__r)rr
r
r�__repr__�szHeaders.__repr__cCsdjdd�|jD�ddg�S)zkstr() returns the formatted headers, complete with end line,
        suitable for direct HTTP transmission.z
cSsg|]}d|�qS)z%s: %sr
)rr r
r
rr!�sz#Headers.__str__.<locals>.<listcomp>�)�joinr)rr
r
r�__str__�szHeaders.__str__cCst|�jd�S)Nz
iso-8859-1)r�encode)rr
r
r�	__bytes__�szHeaders.__bytes__cCs:|j|�}|dkr2|jj|j|�|j|�f�|S|SdS)z�Return first matching header value for 'name', or 'value'

        If there is no header named 'name', add a new header with name 'name'
        and value 'value'.N)r#rrr)rrr	�resultr
r
r�
setdefault�s
zHeaders.setdefaultcKs�g}|dk	r |j|�}|j|�x\|j�D]P\}}|j|�}|dkrX|j|jdd��q*|j|�}|jt|jdd�|��q*W|jj|j|�dj|�f�dS)afExtended header setting.

        _name is the header field to add.  keyword arguments can be used to set
        additional parameters for the header field, with underscores converted
        to dashes.  Normally the parameter will be added as key="value" unless
        value is None, in which case only the key will be added.

        Example:

        h.add_header('content-disposition', 'attachment', filename='bud.gif')

        Note that unlike the corresponding 'email.message' method, this does
        *not* handle '(charset, language, value)' tuples: all values must be
        strings or None.
        N�_�-z; )rrr,rrrr1)r�_nameZ_valueZ_params�partsr(r)r
r
r�
add_header�s



zHeaders.add_header)N)N)r.�
__module__�__qualname__�__doc__rrrrr"r$r%r&r#r*r+r,r/r2r4r6r;r
r
r
rr
s$


	



r
)Nr)r>�re�compilerrr
r
r
r
r�<module>s

__pycache__/__init__.cpython-36.pyc000064400000001316150327211600013137 0ustar003


 \K�@sdZdS)aDwsgiref -- a WSGI (PEP 3333) Reference Library

Current Contents:

* util -- Miscellaneous useful functions and wrappers

* headers -- Manage response headers

* handlers -- base classes for server/gateway implementations

* simple_server -- a simple BaseHTTPServer that supports WSGI

* validate -- validation wrapper that sits between an app and a server
  to detect errors in either

To-Do:

* cgi_gateway -- Run WSGI apps under CGI (pending a deployment standard)

* cgi_wrapper -- Run CGI apps under WSGI

* router -- a simple middleware component that handles URL traversal
N)�__doc__�rr�(/usr/lib64/python3.6/wsgiref/__init__.py�<module>s__pycache__/__init__.cpython-36.opt-1.pyc000064400000001316150327211600014076 0ustar003


 \K�@sdZdS)aDwsgiref -- a WSGI (PEP 3333) Reference Library

Current Contents:

* util -- Miscellaneous useful functions and wrappers

* headers -- Manage response headers

* handlers -- base classes for server/gateway implementations

* simple_server -- a simple BaseHTTPServer that supports WSGI

* validate -- validation wrapper that sits between an app and a server
  to detect errors in either

To-Do:

* cgi_gateway -- Run WSGI apps under CGI (pending a deployment standard)

* cgi_wrapper -- Run CGI apps under WSGI

* router -- a simple middleware component that handles URL traversal
N)�__doc__�rr�(/usr/lib64/python3.6/wsgiref/__init__.py�<module>s__pycache__/handlers.cpython-38.opt-2.pyc000064400000024515150327212340014152 0ustar00U

e5d�T�
@s�ddlmZmZmZddlmZddlZddlZddlZddddd	d
gZ	ddd
ddddgZ
dddddddddddddg
Zdd�Zd d!d"d#d$d%d&d'd(d)h
j
Zd*d+�Zd,d
�ZGd-d�d�ZGd.d�de�ZGd/d�de�ZGd0d�de�ZGd1d	�d	e�ZdS)2�)�FileWrapper�guess_scheme�
is_hop_by_hop)�Headers�N�BaseHandler�
SimpleHandler�BaseCGIHandler�
CGIHandler�
IISCGIHandler�read_environZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc
	Cs:t�|�\	}}}}}}}}}	dt||t|||||fS)Nz#%s, %02d %3s %4d %02d:%02d:%02d GMT)�time�gmtime�_weekdayname�
_monthname)
Z	timestampZyearZmonthZdayZhhZmmZssZwd�y�z�r�(/usr/lib64/python3.8/wsgiref/handlers.py�format_date_times�r�SCRIPT_NAME�	PATH_INFOZQUERY_STRINGZREQUEST_METHODZ	AUTH_TYPEZCONTENT_TYPEZCONTENT_LENGTHZHTTPSZREMOTE_USERZREMOTE_IDENTcCs6t|�p4|�d�p4|�d�p4|�d�o4t|dd��S)NZHTTP_ZSSL_Z	REDIRECT_�	)�_is_request�
startswith�_needs_transcode)�krrrrs�rcCs�t��}d}zd�d|�Wntk
r4d}YnXi}tj��D]�\}}t|�r�tjdkr�tj�	dd��
�}|�d�r�|�d��d�}q�|�d	�r�q�|�d
�r�d|kr�|�d��d�}q�|�|d��d�}n|�||��d�}|||<qD|S)N�surrogateescape�zutf-8�replaceZwin32�SERVER_SOFTWAREzmicrosoft-iis/�
iso-8859-1zapache/zsimplehttp/zpython/3)
�sys�getfilesystemencoding�encode�LookupError�os�environ�itemsr�platform�get�lowerr�decode)�encZescr'r�vZsoftwarerrrr"s0

	

��
c@seZdZdZdZdZdZdZdZdZ	e
�ZeZ
eZdZdZdgZdZdZZdZdZd	Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zd:dd�Zdd�Z dd�Z!dd�Z"dd�Z#d d!�Z$d"d#�Z%d$d%�Z&d&d'�Z'd(d)�Z(d*d+�Z)d,d-�Z*d.d/�Z+d0d1�Z,d2d3�Z-d4d5�Z.d6d7�Z/d8d9�Z0dS);r)rrTFz1.0Nz500 Internal Server Error)zContent-Typez
text/plains;A server error occurred.  Please contact the administrator.rc
Cstz$|��||j|j�|_|��WnJtttfk
r@YdSz|��Wn|�	��YnXYnXdS�N)
�
setup_environr'�start_response�result�finish_response�ConnectionAbortedError�BrokenPipeError�ConnectionResetError�handle_error�close)�selfZapplicationrrr�run�szBaseHandler.runcCs�|j��}|_|��|��|d<|��|d<|j|d<|j|d<|��|d<|j	|d<|j
|d<|jdk	rx|j|d<|jr�|j
r�|�d	|j
�dS)
Nz
wsgi.inputzwsgi.errorszwsgi.versionz
wsgi.run_oncezwsgi.url_schemezwsgi.multithreadzwsgi.multiprocesszwsgi.file_wrapperr )�
os_environ�copyr'�add_cgi_vars�	get_stdin�
get_stderr�wsgi_version�
wsgi_run_once�
get_scheme�wsgi_multithread�wsgi_multiprocess�wsgi_file_wrapper�
origin_server�server_software�
setdefault)r9�envrrrr0�s





zBaseHandler.setup_environcCsdz2|��r|��s0|jD]}|�|�q|��Wn$t|jd�rP|j���Yn
X|��dS)Nr8)�result_is_file�sendfiler2�write�finish_content�hasattrr8�r9�datarrrr3�s

zBaseHandler.finish_responsecCs
t|j�Sr/)rr'�r9rrrrB�szBaseHandler.get_schemec
CsJzt|j�}Wntttfk
r(YnX|dkrFt|j�|jd<dSdS)Nr�Content-Length)�lenr2�	TypeError�AttributeError�NotImplementedError�str�
bytes_sent�headers)r9Zblocksrrr�set_content_length�szBaseHandler.set_content_lengthcCsd|jkr|��dS)NrR)rYrZrQrrr�cleanup_headers�s
zBaseHandler.cleanup_headerscCsh|r2z$|jr&|d|d��|d��W5d}Xn|jdk	rDtd��||_|�|�|_|�|d�}|jS)Nrr�zHeaders already set!ZStatus)�headers_sent�with_tracebackrY�AssertionError�status�
headers_class�_convert_string_typerL)r9r`rY�exc_inforrrr1�s
zBaseHandler.start_responsecCs(t|�tkr|Std�|t|����dS)Nz!{0} must be of type str (got {1}))�typerWr_�format�repr)r9�value�titlerrrrb�s
�z BaseHandler._convert_string_typecCs�|jrx|��r�|�d|j|jf�d��d|jkrP|�dtt����d��|j	r�d|jkr�|�d|j	�d��n|�d|j�d��dS)NzHTTP/%s %s
r!ZDatez
Date: %s
ZServerzServer: %s
zStatus: %s
)
rF�client_is_modern�_write�http_versionr`r$rYrr
rGrQrrr�
send_preambles
�zBaseHandler.send_preamblecCsR|jstd��n,|js*t|�|_|��n|jt|�7_|�|�|��dS)Nzwrite() before start_response())r`r_r]rSrX�send_headersrj�_flushrOrrrrLs



zBaseHandler.writecCsdS)NFrrQrrrrK)szBaseHandler.sendfilecCs"|js|j�dd�|��ndS)NrR�0)r]rYrHrmrQrrrrM>s
zBaseHandler.finish_contentc	CsFzt|jd�r|j��W5d|_|_|_|_d|_d|_XdS)NrFr8)r2rYr`r'rXr]rNr8rQrrrr8HszBaseHandler.closecCs8|��d|_|jr|��r4|��|�t|j��dS)NT)r[r]rFrirlrj�bytesrYrQrrrrmUs
zBaseHandler.send_headerscCs|j}|dk	ot|j|�Sr/)rE�
isinstancer2)r9�wrapperrrrrJ^szBaseHandler.result_is_filecCs|jd��dkS)NZSERVER_PROTOCOLzHTTP/0.9)r'�upperrQrrrridszBaseHandler.client_is_moderncCsJz>ddlm}|��}||d|d|d|j|�|��W5d}XdS)Nr)�print_exceptionrr\)�	tracebackrtr?�traceback_limit�flush)r9rcrt�stderrrrr�
log_exceptionis�zBaseHandler.log_exceptioncCs2|�t���|js.|�|j|j�|_|��dSr/)	ryr"rcr]�error_outputr'r1r2r3rQrrrr7yszBaseHandler.handle_errorcCs$||j|jdd�t���|jgSr/)�error_status�
error_headersr"rc�
error_body)r9r'r1rrrrz�s
zBaseHandler.error_outputcCst�dSr/�rVrOrrrrj�szBaseHandler._writecCst�dSr/r~rQrrrrn�szBaseHandler._flushcCst�dSr/r~rQrrrr>�szBaseHandler.get_stdincCst�dSr/r~rQrrrr?�szBaseHandler.get_stderrcCst�dSr/r~rQrrrr=�szBaseHandler.add_cgi_vars)N)1�__name__�
__module__�__qualname__r@rCrDrArFrkrGrr;rrErrarvr{r|r}r`r2r]rYrXr:r0r3rBrZr[r1rbrlrLrKrMr8rmrJriryr7rzrjrnr>r?r=rrrrr^sT



		c@s>eZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�ZdS)rTFcCs(||_||_||_||_||_||_dSr/)�stdin�stdoutrx�base_envrCrD)r9r�r�rxr'�multithread�multiprocessrrr�__init__�szSimpleHandler.__init__cCs|jSr/)r�rQrrrr>�szSimpleHandler.get_stdincCs|jSr/)rxrQrrrr?�szSimpleHandler.get_stderrcCs|j�|j�dSr/)r'�updater�rQrrrr=�szSimpleHandler.add_cgi_varscCs^|j�|�}|dks |t|�kr$dSddlm}|dt�||d�}|sLqZ|j�|�}q:dS)Nr)�warnz9SimpleHandler.stdout.write() should not do partial writes)r�rLrS�warningsr��DeprecationWarning)r9rPr2r�rrrrj�s�zSimpleHandler._writecCs|j��|jj|_dSr/)r�rwrnrQrrrrn�s
zSimpleHandler._flushN)TF)	rr�r�r�r>r?r=rjrnrrrrr�s�


c@seZdZdZdS)r	FN)rr�r�rFrrrrr	�sc@seZdZdZiZdd�ZdS)r
Tc	Cs(tj|tjjtjjtjt�ddd�dS)NFT�r�r�)r	r�r"r��bufferr�rxrrQrrrr�s�zCGIHandler.__init__N�rr�r�rAr;r�rrrrr
�sc@seZdZdZiZdd�ZdS)rTc	Csjt�}|�dd�}|�dd�}|d�|d�rD|t|�d�|d<tj|tjjtj	jtj
|ddd�dS)Nrrr�/FTr�)rr*rrSr	r�r"r�r�r�rx)r9r'�pathZscriptrrrr�2s�zIISCGIHandler.__init__Nr�rrrrrs)�utilrrrrYrr"r&r
�__all__rrr�__contains__rrrrrr	r
rrrrr�<module>sZ���<V2__pycache__/headers.cpython-38.opt-2.pyc000064400000010574150327212340013765 0ustar00U

e5dn�@s.ddlZe�d�Zddd�ZGdd�d�ZdS)	�Nz[ \(\)<>@,;:\\"/\[\]\?=]�cCsX|dk	rPt|�dkrP|s"t�|�rB|�dd��dd�}d||fSd||fSn|SdS)Nr�\z\\�"z\"z%s="%s"z%s=%s)�len�	tspecials�search�replace)Zparam�valueZquote�r
�'/usr/lib64/python3.8/wsgiref/headers.py�_formatparam
src@s�eZdZd$dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
d%dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�ZdS)&�HeadersNcCs.|dk	r|ng}t|�tk	r$td��||_dS)Nz+Headers must be a list of name/value tuples)�type�list�	TypeError�_headers)�selfZheadersr
r
r�__init__s
zHeaders.__init__cCs&t|�tkr|Std�t|����dS)Nz1Header names/values must be of type str (got {0}))r�str�AssertionError�format�repr)rr	r
r
r�_convert_string_type)s
�zHeaders._convert_string_typecCs
t|j�S�N)rr�rr
r
r�__len__0szHeaders.__len__cCs&||=|j�|�|�|�|�f�dSr)r�appendr)r�name�valr
r
r�__setitem__4s�zHeaders.__setitem__cs0|�������fdd�|jD�|jdd�<dS)Ncs g|]}|d���kr|�qS)r��lower��.0Zkv�rr
r�
<listcomp>@sz'Headers.__delitem__.<locals>.<listcomp>�rr!r�rrr
r$r�__delitem__:szHeaders.__delitem__cCs
|�|�Sr��getr'r
r
r�__getitem__Bs	zHeaders.__getitem__cCs|�|�dk	Srr)r'r
r
r�__contains__MszHeaders.__contains__cs"|�������fdd�|jD�S)Ncs$g|]}|d���kr|d�qS)rrr r"r$r
rr%[sz#Headers.get_all.<locals>.<listcomp>r&r'r
r$r�get_allRszHeaders.get_allcCs6|�|���}|jD]\}}|��|kr|Sq|Srr&)rr�default�k�vr
r
rr*^s

zHeaders.getcCsdd�|jD�S)NcSsg|]\}}|�qSr
r
�r#r/r0r
r
rr%osz Headers.keys.<locals>.<listcomp>�rrr
r
r�keysgszHeaders.keyscCsdd�|jD�S)NcSsg|]\}}|�qSr
r
r1r
r
rr%ysz"Headers.values.<locals>.<listcomp>r2rr
r
r�valuesqszHeaders.valuescCs|jdd�Srr2rr
r
r�items{sz
Headers.itemscCsd|jj|jfS)Nz%s(%r))�	__class__�__name__rrr
r
r�__repr__�szHeaders.__repr__cCsd�dd�|jD�ddg�S)Nz
cSsg|]}d|�qS)z%s: %sr
r"r
r
rr%�sz#Headers.__str__.<locals>.<listcomp>�)�joinrrr
r
r�__str__�szHeaders.__str__cCst|��d�S)Nz
iso-8859-1)r�encoderr
r
r�	__bytes__�szHeaders.__bytes__cCs:|�|�}|dkr2|j�|�|�|�|�f�|S|SdSr)r*rrr)rrr	�resultr
r
r�
setdefault�s
�zHeaders.setdefaultcKs�g}|dk	r |�|�}|�|�|��D]P\}}|�|�}|dkrV|�|�dd��q(|�|�}|�t|�dd�|��q(|j�|�|�d�|�f�dS)N�_�-z; )rrr5rrrr:)r�_nameZ_valueZ_params�partsr/r0r
r
r�
add_header�s



zHeaders.add_header)N)N)r7�
__module__�__qualname__rrrrr(r+r,r-r*r3r4r5r8r;r=r?rDr
r
r
rr
s"


	



r
)Nr)�re�compilerrr
r
r
r
r�<module>
s

__pycache__/util.cpython-38.opt-1.pyc000064400000012446150327212340013326 0ustar00U

e5d��@svdZddlZddddddgZGd	d�d�Zd
d�Zdd�Zdd
d�Zdd�Zdd�Zddddddddhj	Z
dd�ZdS)z$Miscellaneous WSGI-related Utilities�N�FileWrapper�guess_scheme�application_uri�request_uri�shift_path_info�setup_testing_defaultsc@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)
rz1Wrapper to convert file-like objects to iterables� cCs"||_||_t|d�r|j|_dS)N�close)�filelike�blksize�hasattrr	)�selfr
r�r�$/usr/lib64/python3.8/wsgiref/util.py�__init__s
zFileWrapper.__init__cCs6ddl}|jdtdd�|j�|j�}|r.|St�dS)NrzXFileWrapper's __getitem__ method ignores 'key' parameter. Use iterator protocol instead.�)�
stacklevel)�warnings�warn�DeprecationWarningr
�readr�
IndexError)r
�keyr�datarrr�__getitem__s�zFileWrapper.__getitem__cCs|S�Nr)r
rrr�__iter__!szFileWrapper.__iter__cCs|j�|j�}|r|St�dSr)r
rr�
StopIteration)r
rrrr�__next__$szFileWrapper.__next__N)r)�__name__�
__module__�__qualname__�__doc__rrrrrrrrrs


cCs|�d�dkrdSdSdS)zMReturn a guess for whether 'wsgi.url_scheme' should be 'http' or 'https'
    ZHTTPS)ZyesZon�1�https�httpN)�get)�environrrrr*scCs�|dd}ddlm}|�d�r0||d7}nR||d7}|ddkrf|dd	kr�|d
|d7}n|ddkr�|d
|d7}|||�d�p�d
dd�7}|S)z@Return the application's base URI (no PATH_INFO or QUERY_STRING)�wsgi.url_schemez://r��quote�	HTTP_HOST�SERVER_NAMEr$�SERVER_PORT�443�:�80�SCRIPT_NAME�/�latin1)�encoding)�urllib.parser*r&)r'�urlr*rrrr2s
TcCspt|�}ddlm}||�dd�ddd�}|�d�sF||d	d
�7}n||7}|rl|�d�rl|d|d7}|S)
zBReturn the full request URI, optionally including the query stringrr)�	PATH_INFO�z/;=,r3)Zsafer4r1�NZQUERY_STRING�?)rr5r*r&)r'Z
include_queryr6r*�	path_inforrrrFs
cCs�|�dd�}|sdS|�d�}dd�|dd�D�|dd�<|d}|d=|�d	d�}t�|d|�}|�d�r~|dd�}|s�|�d�s�|d7}||d	<d�|�|d<|d
kr�d}|S)aZShift a name from PATH_INFO to SCRIPT_NAME, returning it

    If there are no remaining path segments in PATH_INFO, return None.
    Note: 'environ' is modified in-place; use a copy if you need to keep
    the original PATH_INFO or SCRIPT_NAME.

    Note: when PATH_INFO is just a '/', this returns '' and appends a trailing
    '/' to SCRIPT_NAME, even though empty path segments are normally ignored,
    and SCRIPT_NAME doesn't normally end in a '/'.  This is intentional
    behavior, to ensure that an application can tell the difference between
    '/x' and '/x/' when traversing to objects.
    r7r8Nr2cSsg|]}|r|dkr|�qS)�.r)�.0�prrr�
<listcomp>esz#shift_path_info.<locals>.<listcomp>r9���r1r<)r&�split�	posixpath�normpath�endswith�join)r'r;�
path_parts�nameZscript_namerrrrSs$


cCs�|�dd�|�dd�|�d|d�|�dd�d|kr\d	|kr\|�dd
�|�d	d�|�dd
�|�dd�|�dd�|�dd�ddlm}m}|�d|��|�d|��|�dt|��|ddkr�|�dd�n|ddkr�|�dd�dS)a:Update 'environ' with trivial defaults for testing purposes

    This adds various parameters required for WSGI, including HTTP_HOST,
    SERVER_NAME, SERVER_PORT, REQUEST_METHOD, SCRIPT_NAME, PATH_INFO,
    and all of the wsgi.* variables.  It only supplies default values,
    and does not replace any existing settings for these variables.

    This routine is intended to make it easier for unit tests of WSGI
    servers and applications to set up dummy environments.  It should *not*
    be used by actual WSGI servers or applications, since the data is fake!
    r,z	127.0.0.1ZSERVER_PROTOCOLzHTTP/1.0r+ZREQUEST_METHODZGETr1r7r8r2zwsgi.version)r9rz
wsgi.run_oncerzwsgi.multithreadzwsgi.multiprocess)�StringIO�BytesIOz
wsgi.inputzwsgi.errorsr(r%r-r0r$r.N)�
setdefault�iorHrIr)r'rHrIrrrr|s&
Z
connectionz
keep-alivezproxy-authenticatezproxy-authorizationZteZtrailersztransfer-encodingZupgradecCst|���S)z?Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header)�_hoppish�lower)Zheader_namerrr�
is_hop_by_hop�srN)T)r"rB�__all__rrrrrr�__contains__rLrNrrrr�<module>s0�

))�__pycache__/util.cpython-38.pyc000064400000012446150327212340012367 0ustar00U

e5d��@svdZddlZddddddgZGd	d�d�Zd
d�Zdd�Zdd
d�Zdd�Zdd�Zddddddddhj	Z
dd�ZdS)z$Miscellaneous WSGI-related Utilities�N�FileWrapper�guess_scheme�application_uri�request_uri�shift_path_info�setup_testing_defaultsc@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)
rz1Wrapper to convert file-like objects to iterables� cCs"||_||_t|d�r|j|_dS)N�close)�filelike�blksize�hasattrr	)�selfr
r�r�$/usr/lib64/python3.8/wsgiref/util.py�__init__s
zFileWrapper.__init__cCs6ddl}|jdtdd�|j�|j�}|r.|St�dS)NrzXFileWrapper's __getitem__ method ignores 'key' parameter. Use iterator protocol instead.�)�
stacklevel)�warnings�warn�DeprecationWarningr
�readr�
IndexError)r
�keyr�datarrr�__getitem__s�zFileWrapper.__getitem__cCs|S�Nr)r
rrr�__iter__!szFileWrapper.__iter__cCs|j�|j�}|r|St�dSr)r
rr�
StopIteration)r
rrrr�__next__$szFileWrapper.__next__N)r)�__name__�
__module__�__qualname__�__doc__rrrrrrrrrs


cCs|�d�dkrdSdSdS)zMReturn a guess for whether 'wsgi.url_scheme' should be 'http' or 'https'
    ZHTTPS)ZyesZon�1�https�httpN)�get)�environrrrr*scCs�|dd}ddlm}|�d�r0||d7}nR||d7}|ddkrf|dd	kr�|d
|d7}n|ddkr�|d
|d7}|||�d�p�d
dd�7}|S)z@Return the application's base URI (no PATH_INFO or QUERY_STRING)�wsgi.url_schemez://r��quote�	HTTP_HOST�SERVER_NAMEr$�SERVER_PORT�443�:�80�SCRIPT_NAME�/�latin1)�encoding)�urllib.parser*r&)r'�urlr*rrrr2s
TcCspt|�}ddlm}||�dd�ddd�}|�d�sF||d	d
�7}n||7}|rl|�d�rl|d|d7}|S)
zBReturn the full request URI, optionally including the query stringrr)�	PATH_INFO�z/;=,r3)Zsafer4r1�NZQUERY_STRING�?)rr5r*r&)r'Z
include_queryr6r*�	path_inforrrrFs
cCs�|�dd�}|sdS|�d�}dd�|dd�D�|dd�<|d}|d=|�d	d�}t�|d|�}|�d�r~|dd�}|s�|�d�s�|d7}||d	<d�|�|d<|d
kr�d}|S)aZShift a name from PATH_INFO to SCRIPT_NAME, returning it

    If there are no remaining path segments in PATH_INFO, return None.
    Note: 'environ' is modified in-place; use a copy if you need to keep
    the original PATH_INFO or SCRIPT_NAME.

    Note: when PATH_INFO is just a '/', this returns '' and appends a trailing
    '/' to SCRIPT_NAME, even though empty path segments are normally ignored,
    and SCRIPT_NAME doesn't normally end in a '/'.  This is intentional
    behavior, to ensure that an application can tell the difference between
    '/x' and '/x/' when traversing to objects.
    r7r8Nr2cSsg|]}|r|dkr|�qS)�.r)�.0�prrr�
<listcomp>esz#shift_path_info.<locals>.<listcomp>r9���r1r<)r&�split�	posixpath�normpath�endswith�join)r'r;�
path_parts�nameZscript_namerrrrSs$


cCs�|�dd�|�dd�|�d|d�|�dd�d|kr\d	|kr\|�dd
�|�d	d�|�dd
�|�dd�|�dd�|�dd�ddlm}m}|�d|��|�d|��|�dt|��|ddkr�|�dd�n|ddkr�|�dd�dS)a:Update 'environ' with trivial defaults for testing purposes

    This adds various parameters required for WSGI, including HTTP_HOST,
    SERVER_NAME, SERVER_PORT, REQUEST_METHOD, SCRIPT_NAME, PATH_INFO,
    and all of the wsgi.* variables.  It only supplies default values,
    and does not replace any existing settings for these variables.

    This routine is intended to make it easier for unit tests of WSGI
    servers and applications to set up dummy environments.  It should *not*
    be used by actual WSGI servers or applications, since the data is fake!
    r,z	127.0.0.1ZSERVER_PROTOCOLzHTTP/1.0r+ZREQUEST_METHODZGETr1r7r8r2zwsgi.version)r9rz
wsgi.run_oncerzwsgi.multithreadzwsgi.multiprocess)�StringIO�BytesIOz
wsgi.inputzwsgi.errorsr(r%r-r0r$r.N)�
setdefault�iorHrIr)r'rHrIrrrr|s&
Z
connectionz
keep-alivezproxy-authenticatezproxy-authorizationZteZtrailersztransfer-encodingZupgradecCst|���S)z?Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header)�_hoppish�lower)Zheader_namerrr�
is_hop_by_hop�srN)T)r"rB�__all__rrrrrr�__contains__rLrNrrrr�<module>s0�

))�__pycache__/headers.cpython-38.opt-1.pyc000064400000017031150327212340013757 0ustar00U

e5dn�@s2dZddlZe�d�Zd	dd�ZGdd�d�ZdS)
z�Manage HTTP Response Headers

Much of this module is red-handedly pilfered from email.message in the stdlib,
so portions are Copyright (C) 2001,2002 Python Software Foundation, and were
written by Barry Warsaw.
�Nz[ \(\)<>@,;:\\"/\[\]\?=]�cCsX|dk	rPt|�dkrP|s"t�|�rB|�dd��dd�}d||fSd||fSn|SdS)	z~Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.
    Nr�\z\\�"z\"z%s="%s"z%s=%s)�len�	tspecials�search�replace)Zparam�valueZquote�r
�'/usr/lib64/python3.8/wsgiref/headers.py�_formatparam
src@s�eZdZdZd%dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zd&dd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�ZdS)'�Headersz,Manage a collection of HTTP response headersNcCs.|dk	r|ng}t|�tk	r$td��||_dS)Nz+Headers must be a list of name/value tuples)�type�list�	TypeError�_headers)�selfZheadersr
r
r�__init__s
zHeaders.__init__cCs&t|�tkr|Std�t|����dS)zConvert/check value type.z1Header names/values must be of type str (got {0})N)r�str�AssertionError�format�repr)rr	r
r
r�_convert_string_type)s
�zHeaders._convert_string_typecCs
t|j�S)z9Return the total number of headers, including duplicates.)rr�rr
r
r�__len__0szHeaders.__len__cCs&||=|j�|�|�|�|�f�dS)zSet the value of a header.N)r�appendr)r�name�valr
r
r�__setitem__4s�zHeaders.__setitem__cs0|�������fdd�|jD�|jdd�<dS)zyDelete all occurrences of a header, if present.

        Does *not* raise an exception if the header is missing.
        cs g|]}|d���kr|�qS)r��lower��.0Zkv�rr
r�
<listcomp>@sz'Headers.__delitem__.<locals>.<listcomp>N�rr r�rrr
r#r�__delitem__:szHeaders.__delitem__cCs
|�|�S)aHGet the first header value for 'name'

        Return None if the header is missing instead of raising an exception.

        Note that if the header appeared multiple times, the first exactly which
        occurrence gets returned is undefined.  Use getall() to get all
        the values matching a header field name.
        ��getr&r
r
r�__getitem__Bs	zHeaders.__getitem__cCs|�|�dk	S)z/Return true if the message contains the header.Nr(r&r
r
r�__contains__MszHeaders.__contains__cs"|�������fdd�|jD�S)aqReturn a list of all the values for the named field.

        These will be sorted in the order they appeared in the original header
        list or were added to this instance, and may contain duplicates.  Any
        fields deleted and re-inserted are always appended to the header list.
        If no fields exist with the given name, returns an empty list.
        cs$g|]}|d���kr|d�qS)rrrr!r#r
rr$[sz#Headers.get_all.<locals>.<listcomp>r%r&r
r#r�get_allRszHeaders.get_allcCs6|�|���}|jD]\}}|��|kr|Sq|S)z:Get the first header value for 'name', or return 'default'r%)rr�default�k�vr
r
rr)^s

zHeaders.getcCsdd�|jD�S)a*Return a list of all the header field names.

        These will be sorted in the order they appeared in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cSsg|]\}}|�qSr
r
�r"r.r/r
r
rr$osz Headers.keys.<locals>.<listcomp>�rrr
r
r�keysgszHeaders.keyscCsdd�|jD�S)a!Return a list of all header values.

        These will be sorted in the order they appeared in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cSsg|]\}}|�qSr
r
r0r
r
rr$ysz"Headers.values.<locals>.<listcomp>r1rr
r
r�valuesqszHeaders.valuescCs|jdd�S)aGet all the header fields and values.

        These will be sorted in the order they were in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        Nr1rr
r
r�items{sz
Headers.itemscCsd|jj|jfS)Nz%s(%r))�	__class__�__name__rrr
r
r�__repr__�szHeaders.__repr__cCsd�dd�|jD�ddg�S)zkstr() returns the formatted headers, complete with end line,
        suitable for direct HTTP transmission.z
cSsg|]}d|�qS)z%s: %sr
r!r
r
rr$�sz#Headers.__str__.<locals>.<listcomp>�)�joinrrr
r
r�__str__�szHeaders.__str__cCst|��d�S)Nz
iso-8859-1)r�encoderr
r
r�	__bytes__�szHeaders.__bytes__cCs:|�|�}|dkr2|j�|�|�|�|�f�|S|SdS)z�Return first matching header value for 'name', or 'value'

        If there is no header named 'name', add a new header with name 'name'
        and value 'value'.N)r)rrr)rrr	�resultr
r
r�
setdefault�s
�zHeaders.setdefaultcKs�g}|dk	r |�|�}|�|�|��D]P\}}|�|�}|dkrV|�|�dd��q(|�|�}|�t|�dd�|��q(|j�|�|�d�|�f�dS)afExtended header setting.

        _name is the header field to add.  keyword arguments can be used to set
        additional parameters for the header field, with underscores converted
        to dashes.  Normally the parameter will be added as key="value" unless
        value is None, in which case only the key will be added.

        Example:

        h.add_header('content-disposition', 'attachment', filename='bud.gif')

        Note that unlike the corresponding 'email.message' method, this does
        *not* handle '(charset, language, value)' tuples: all values must be
        strings or None.
        N�_�-z; )rrr4rrrr9)r�_nameZ_valueZ_params�partsr.r/r
r
r�
add_header�s



zHeaders.add_header)N)N)r6�
__module__�__qualname__�__doc__rrrrr'r*r+r,r)r2r3r4r7r:r<r>rCr
r
r
rr
s$


	



r
)Nr)rF�re�compilerrr
r
r
r
r�<module>s	

__pycache__/simple_server.cpython-38.opt-2.pyc000064400000010612150327212340015222 0ustar00U

e5d3�	@sddlmZmZddlZddlZddlmZddlm	Z	dZ
dddd	gZd
e
Ze	�dej
��dZedeZGd
d�de�ZGdd�de�ZGdd�de�Zdd�Zeefdd	�Zedk�redde��BZej��Zededdedd�ddlZe�d�e��W5QRXdS)�)�BaseHTTPRequestHandler�
HTTPServerN)�
SimpleHandler)�python_implementationz0.2�
WSGIServer�WSGIRequestHandler�demo_app�make_server�WSGIServer/�/� c@seZdZeZdd�ZdS)�
ServerHandlerc	Cs4z"|j�|j�dd�d|j�W5t�|�XdS)Nr�r)r�close�request_handlerZlog_requestZstatus�splitZ
bytes_sent��self�r�-/usr/lib64/python3.8/wsgiref/simple_server.pyr s�zServerHandler.closeN)�__name__�
__module__�__qualname__�software_versionZserver_softwarerrrrrr
sr
c@s0eZdZdZdd�Zdd�Zdd�Zdd	�ZdS)
rNcCst�|�|��dS�N)r�server_bind�
setup_environrrrrr0s
zWSGIServer.server_bindcCsFi}|_|j|d<d|d<t|j�|d<d|d<d|d<d|d<dS)	NZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PORT��REMOTE_HOST�CONTENT_LENGTHZSCRIPT_NAME)�base_environZserver_name�strZserver_port)r�envrrrr5s

zWSGIServer.setup_environcCs|jSr��applicationrrrr�get_app?szWSGIServer.get_appcCs
||_dSrr#)rr$rrr�set_appBszWSGIServer.set_app)rrrr$rrr%r&rrrrr*s

c@s,eZdZdeZdd�Zdd�Zdd�ZdS)	rr
cCsP|jj��}|j|d<|j|d<|j|d<d|jkrH|j�dd�\}}n|jd}}tj	�
|d�|d<||d	<|��}||jd
kr�||d<|jd
|d<|j
�d
�dkr�|j
��|d<n|j
d
|d<|j
�d�}|r�||d<|j
��D]`\}}|�dd���}|��}||k�rq�d||k�r>|d|d|7<q�||d|<q�|S)NZSERVER_PROTOCOLZSERVER_SOFTWAREZREQUEST_METHOD�?rrz
iso-8859-1Z	PATH_INFOZQUERY_STRINGrrZREMOTE_ADDRzcontent-typeZCONTENT_TYPEzcontent-lengthr�-�_ZHTTP_�,)�serverr �copy�request_version�server_version�command�pathr�urllib�parseZunquoteZaddress_stringZclient_addressZheaders�getZget_content_type�items�replace�upper�strip)rr"r0Zquery�hostZlength�k�vrrr�get_environKs8




zWSGIRequestHandler.get_environcCstjSr)�sys�stderrrrrr�
get_stderrpszWSGIRequestHandler.get_stderrcCs�|j�d�|_t|j�dkr<d|_d|_d|_|�d�dS|��sHdSt	|j|j
|��|��dd�}||_
|�|j���dS)Niiri�F)Zmultithread)Zrfile�readlineZraw_requestline�lenZrequestliner-r/Z
send_errorZ
parse_requestr
Zwfiler>r;r�runr+r%)rZhandlerrrr�handless$
�zWSGIRequestHandler.handleN)rrr�__version__r.r;r>rBrrrrrGs%cCsrddlm}|�}td|d�t|d�t|���}|D]\}}t|dt|�|d�q8|ddg�|���d�gS)	Nr)�StringIOzHello world!)�file�=z200 OK)zContent-Typeztext/plain; charset=utf-8zutf-8)�iorD�print�sortedr4�repr�getvalue�encode)�environZstart_responserD�stdout�hr9r:rrrr�s
cCs|||f|�}|�|�|Sr)r&)r8�portZappZserver_classZ
handler_classr+rrrr	�s
�__main__ri@zServing HTTP onrPrz...zhttp://localhost:8000/xyz?abc)Zhttp.serverrrr<Zurllib.parser1Zwsgiref.handlersr�platformrrC�__all__r.�versionr�sys_versionrr
rrrr	rZhttpdZsocketZgetsocknameZsarHZ
webbrowser�openZhandle_requestrrrr�<module>
s.C
�
	


__pycache__/__init__.cpython-38.opt-1.pyc000064400000001326150327212340014103 0ustar00U

e5dK�@sdZdS)aDwsgiref -- a WSGI (PEP 3333) Reference Library

Current Contents:

* util -- Miscellaneous useful functions and wrappers

* headers -- Manage response headers

* handlers -- base classes for server/gateway implementations

* simple_server -- a simple BaseHTTPServer that supports WSGI

* validate -- validation wrapper that sits between an app and a server
  to detect errors in either

To-Do:

* cgi_gateway -- Run WSGI apps under CGI (pending a deployment standard)

* cgi_wrapper -- Run CGI apps under WSGI

* router -- a simple middleware component that handles URL traversal
N)�__doc__�rr�(/usr/lib64/python3.8/wsgiref/__init__.py�<module>�__pycache__/__init__.cpython-38.opt-2.pyc000064400000000203150327212340014075 0ustar00U

e5dK�@sdS)N�rrr�(/usr/lib64/python3.8/wsgiref/__init__.py�<module>�__pycache__/handlers.cpython-38.opt-1.pyc000064400000037156150327212340014156 0ustar00U

e5d�T�
@sdZddlmZmZmZddlmZddlZddlZddl	Z	dddd	d
dgZ
dd
dddddgZdddddddddddddg
Zdd �Z
d!d"d#d$d%d&d'd(d)d*h
jZd+d,�Zd-d�ZGd.d�d�ZGd/d�de�ZGd0d�de�ZGd1d	�d	e�ZGd2d
�d
e�ZdS)3z/Base classes for server/gateway implementations�)�FileWrapper�guess_scheme�
is_hop_by_hop)�Headers�N�BaseHandler�
SimpleHandler�BaseCGIHandler�
CGIHandler�
IISCGIHandler�read_environZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc
	Cs:t�|�\	}}}}}}}}}	dt||t|||||fS)Nz#%s, %02d %3s %4d %02d:%02d:%02d GMT)�time�gmtime�_weekdayname�
_monthname)
Z	timestampZyearZmonthZdayZhhZmmZssZwd�y�z�r�(/usr/lib64/python3.8/wsgiref/handlers.py�format_date_times�r�SCRIPT_NAME�	PATH_INFOZQUERY_STRINGZREQUEST_METHODZ	AUTH_TYPEZCONTENT_TYPEZCONTENT_LENGTHZHTTPSZREMOTE_USERZREMOTE_IDENTcCs6t|�p4|�d�p4|�d�p4|�d�o4t|dd��S)NZHTTP_ZSSL_Z	REDIRECT_�	)�_is_request�
startswith�_needs_transcode)�krrrrs�rcCs�t��}d}zd�d|�Wntk
r4d}YnXi}tj��D]�\}}t|�r�tjdkr�tj�	dd��
�}|�d�r�|�d��d�}q�|�d	�r�q�|�d
�r�d|kr�|�d��d�}q�|�|d��d�}n|�||��d�}|||<qD|S)z'Read environment, fixing HTTP variables�surrogateescape�zutf-8�replaceZwin32�SERVER_SOFTWAREzmicrosoft-iis/�
iso-8859-1zapache/zsimplehttp/zpython/3)
�sys�getfilesystemencoding�encode�LookupError�os�environ�itemsr�platform�get�lowerr�decode)�encZescr'r�vZsoftwarerrrr"s0

	

��
c@s"eZdZdZdZdZdZdZdZdZ	dZ
e�Ze
ZeZdZdZdgZd	ZdZZdZdZd
Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zd;dd�Z dd�Z!dd�Z"dd�Z#dd �Z$d!d"�Z%d#d$�Z&d%d&�Z'd'd(�Z(d)d*�Z)d+d,�Z*d-d.�Z+d/d0�Z,d1d2�Z-d3d4�Z.d5d6�Z/d7d8�Z0d9d:�Z1dS)<rz+Manage the invocation of a WSGI application)rrTFz1.0Nz500 Internal Server Error)zContent-Typez
text/plains;A server error occurred.  Please contact the administrator.rc
Cstz$|��||j|j�|_|��WnJtttfk
r@YdSz|��Wn|�	��YnXYnXdS)zInvoke the applicationN)
�
setup_environr'�start_response�result�finish_response�ConnectionAbortedError�BrokenPipeError�ConnectionResetError�handle_error�close)�selfZapplicationrrr�run�szBaseHandler.runcCs�|j��}|_|��|��|d<|��|d<|j|d<|j|d<|��|d<|j	|d<|j
|d<|jdk	rx|j|d	<|jr�|j
r�|�d
|j
�dS)z&Set up the environment for one requestz
wsgi.inputzwsgi.errorszwsgi.versionz
wsgi.run_oncezwsgi.url_schemezwsgi.multithreadzwsgi.multiprocessNzwsgi.file_wrapperr )�
os_environ�copyr'�add_cgi_vars�	get_stdin�
get_stderr�wsgi_version�
wsgi_run_once�
get_scheme�wsgi_multithread�wsgi_multiprocess�wsgi_file_wrapper�
origin_server�server_software�
setdefault)r8�envrrrr/�s





zBaseHandler.setup_environcCsdz2|��r|��s0|jD]}|�|�q|��Wn$t|jd�rP|j���Yn
X|��dS)a>Send any iterable data, then close self and the iterable

        Subclasses intended for use in asynchronous servers will
        want to redefine this method, such that it sets up callbacks
        in the event loop to iterate over the data, and to call
        'self.close()' once the response is finished.
        r7N)�result_is_file�sendfiler1�write�finish_content�hasattrr7�r8�datarrrr2�s

zBaseHandler.finish_responsecCs
t|j�S)z Return the URL scheme being used)rr'�r8rrrrA�szBaseHandler.get_schemec
CsJzt|j�}Wntttfk
r(YnX|dkrFt|j�|jd<dSdS)z@Compute Content-Length or switch to chunked encoding if possibler�Content-LengthN)�lenr1�	TypeError�AttributeError�NotImplementedError�str�
bytes_sent�headers)r8Zblocksrrr�set_content_length�szBaseHandler.set_content_lengthcCsd|jkr|��dS)zqMake any necessary header changes or defaults

        Subclasses can extend this to add other defaults.
        rQN)rXrYrPrrr�cleanup_headers�s
zBaseHandler.cleanup_headerscCsh|r2z$|jr&|d|d��|d��W5d}Xn|jdk	rDtd��||_|�|�|_|�|d�}|jS)z4'start_response()' callable as specified by PEP 3333Nrr�zHeaders already set!ZStatus)�headers_sent�with_tracebackrX�AssertionError�status�
headers_class�_convert_string_typerK)r8r_rX�exc_inforrrr0�s
zBaseHandler.start_responsecCs(t|�tkr|Std�|t|����dS)zConvert/check value type.z!{0} must be of type str (got {1})N)�typerVr^�format�repr)r8�value�titlerrrra�s
�z BaseHandler._convert_string_typecCs�|jrx|��r�|�d|j|jf�d��d|jkrP|�dtt����d��|j	r�d|jkr�|�d|j	�d��n|�d|j�d��dS)	z6Transmit version/status/date/server, via self._write()zHTTP/%s %s
r!ZDatez
Date: %s
ZServerzServer: %s
zStatus: %s
N)
rE�client_is_modern�_write�http_versionr_r$rXrr
rFrPrrr�
send_preambles
�zBaseHandler.send_preamblecCsR|jstd��n,|js*t|�|_|��n|jt|�7_|�|�|��dS)z+'write()' callable as specified by PEP 3333zwrite() before start_response()N)r_r^r\rRrW�send_headersri�_flushrNrrrrKs



zBaseHandler.writecCsdS)aPlatform-specific file transmission

        Override this method in subclasses to support platform-specific
        file transmission.  It is only called if the application's
        return iterable ('self.result') is an instance of
        'self.wsgi_file_wrapper'.

        This method should return a true value if it was able to actually
        transmit the wrapped file-like object using a platform-specific
        approach.  It should return a false value if normal iteration
        should be used instead.  An exception can be raised to indicate
        that transmission was attempted, but failed.

        NOTE: this method should call 'self.send_headers()' if
        'self.headers_sent' is false and it is going to attempt direct
        transmission of the file.
        FrrPrrrrJ)szBaseHandler.sendfilecCs"|js|j�dd�|��ndS)z.Ensure headers and content have both been sentrQ�0N)r\rXrGrlrPrrrrL>s
zBaseHandler.finish_contentc	CsFzt|jd�r|j��W5d|_|_|_|_d|_d|_XdS)z�Close the iterable (if needed) and reset all instance vars

        Subclasses may want to also drop the client connection.
        NrFr7)r1rXr_r'rWr\rMr7rPrrrr7HszBaseHandler.closecCs8|��d|_|jr|��r4|��|�t|j��dS)z1Transmit headers to the client, via self._write()TN)rZr\rErhrkri�bytesrXrPrrrrlUs
zBaseHandler.send_headerscCs|j}|dk	ot|j|�S)z@True if 'self.result' is an instance of 'self.wsgi_file_wrapper'N)rD�
isinstancer1)r8�wrapperrrrrI^szBaseHandler.result_is_filecCs|jd��dkS)z,True if client can accept status and headersZSERVER_PROTOCOLzHTTP/0.9)r'�upperrPrrrrhdszBaseHandler.client_is_moderncCsJz>ddlm}|��}||d|d|d|j|�|��W5d}XdS)z�Log the 'exc_info' tuple in the server log

        Subclasses may override to retarget the output or change its format.
        Nr)�print_exceptionrr[)�	tracebackrsr>�traceback_limit�flush)r8rbrs�stderrrrr�
log_exceptionis�zBaseHandler.log_exceptioncCs2|�t���|js.|�|j|j�|_|��dS)z>Log current error, and send error output to client if possibleN)	rxr"rbr\�error_outputr'r0r1r2rPrrrr6yszBaseHandler.handle_errorcCs$||j|jdd�t���|jgS)aZWSGI mini-app to create error output

        By default, this just uses the 'error_status', 'error_headers',
        and 'error_body' attributes to generate an output page.  It can
        be overridden in a subclass to dynamically generate diagnostics,
        choose an appropriate message for the user's preferred language, etc.

        Note, however, that it's not recommended from a security perspective to
        spit out diagnostics to any old user; ideally, you should have to do
        something special to enable diagnostic output, which is why we don't
        include any here!
        N)�error_status�
error_headersr"rb�
error_body)r8r'r0rrrry�s
zBaseHandler.error_outputcCst�dS)aOverride in subclass to buffer data for send to client

        It's okay if this method actually transmits the data; BaseHandler
        just separates write and flush operations for greater efficiency
        when the underlying system actually has such a distinction.
        N�rUrNrrrri�szBaseHandler._writecCst�dS)z�Override in subclass to force sending of recent '_write()' calls

        It's okay if this method is a no-op (i.e., if '_write()' actually
        sends the data.
        Nr}rPrrrrm�szBaseHandler._flushcCst�dS)z4Override in subclass to return suitable 'wsgi.input'Nr}rPrrrr=�szBaseHandler.get_stdincCst�dS)z5Override in subclass to return suitable 'wsgi.errors'Nr}rPrrrr>�szBaseHandler.get_stderrcCst�dS)z>Override in subclass to insert CGI variables in 'self.environ'Nr}rPrrrr<�szBaseHandler.add_cgi_vars)N)2�__name__�
__module__�__qualname__�__doc__r?rBrCr@rErjrFrr:rrDrr`rurzr{r|r_r1r\rXrWr9r/r2rArYrZr0rarkrKrJrLr7rlrIrhrxr6ryrirmr=r>r<rrrrr^sV



		c@sBeZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)raqHandler that's just initialized with streams, environment, etc.

    This handler subclass is intended for synchronous HTTP/1.0 origin servers,
    and handles sending the entire response output, given the correct inputs.

    Usage::

        handler = SimpleHandler(
            inp,out,err,env, multithread=False, multiprocess=True
        )
        handler.run(app)TFcCs(||_||_||_||_||_||_dS�N)�stdin�stdoutrw�base_envrBrC)r8r�r�rwr'�multithread�multiprocessrrr�__init__�szSimpleHandler.__init__cCs|jSr�)r�rPrrrr=�szSimpleHandler.get_stdincCs|jSr�)rwrPrrrr>�szSimpleHandler.get_stderrcCs|j�|j�dSr�)r'�updater�rPrrrr<�szSimpleHandler.add_cgi_varscCs^|j�|�}|dks |t|�kr$dSddlm}|dt�||d�}|sLqZ|j�|�}q:dS)Nr)�warnz9SimpleHandler.stdout.write() should not do partial writes)r�rKrR�warningsr��DeprecationWarning)r8rOr1r�rrrri�s�zSimpleHandler._writecCs|j��|jj|_dSr�)r�rvrmrPrrrrm�s
zSimpleHandler._flushN)TF)
r~rr�r�r�r=r>r<rirmrrrrr�s
�


c@seZdZdZdZdS)r	a�CGI-like systems using input/output/error streams and environ mapping

    Usage::

        handler = BaseCGIHandler(inp,out,err,env)
        handler.run(app)

    This handler class is useful for gateway protocols like ReadyExec and
    FastCGI, that have usable input/output/error streams and an environment
    mapping.  It's also the base class for CGIHandler, which just uses
    sys.stdin, os.environ, and so on.

    The constructor also takes keyword arguments 'multithread' and
    'multiprocess' (defaulting to 'True' and 'False' respectively) to control
    the configuration sent to the application.  It sets 'origin_server' to
    False (to enable CGI-like output), and assumes that 'wsgi.run_once' is
    False.
    FN)r~rr�r�rErrrrr	�sc@s eZdZdZdZiZdd�ZdS)r
a�CGI-based invocation via sys.stdin/stdout/stderr and os.environ

    Usage::

        CGIHandler().run(app)

    The difference between this class and BaseCGIHandler is that it always
    uses 'wsgi.run_once' of 'True', 'wsgi.multithread' of 'False', and
    'wsgi.multiprocess' of 'True'.  It does not take any initialization
    parameters, but always uses 'sys.stdin', 'os.environ', and friends.

    If you need to override any of these parameters, use BaseCGIHandler
    instead.
    Tc	Cs(tj|tjjtjjtjt�ddd�dS)NFT�r�r�)r	r�r"r��bufferr�rwrrPrrrr�s�zCGIHandler.__init__N�r~rr�r�r@r:r�rrrrr
�sc@s eZdZdZdZiZdd�ZdS)raCGI-based invocation with workaround for IIS path bug

    This handler should be used in preference to CGIHandler when deploying on
    Microsoft IIS without having set the config allowPathInfo option (IIS>=7)
    or metabase allowPathInfoForScriptMappings (IIS<7).
    Tc	Csjt�}|�dd�}|�dd�}|d�|d�rD|t|�d�|d<tj|tjjtj	jtj
|ddd�dS)Nrrr�/FTr�)rr*rrRr	r�r"r�r�r�rw)r8r'�pathZscriptrrrr�2s�zIISCGIHandler.__init__Nr�rrrrrs)r��utilrrrrXrr"r&r
�__all__rrr�__contains__rrrrrr	r
rrrrr�<module>s\���<V2__pycache__/simple_server.cpython-38.pyc000064400000012217150327212340014265 0ustar00U

e5d3�	@s dZddlmZmZddlZddlZddlmZddl	m
Z
dZddd	d
gZdeZ
e
�dej��dZe
d
eZGdd�de�ZGdd�de�ZGdd�de�Zdd	�Zeefdd
�Zedk�redde��BZej��Zededdedd�ddlZe�d�e��W5QRXdS)a!BaseHTTPServer that implements the Python WSGI protocol (PEP 3333)

This is both an example of how WSGI can be implemented, and a basis for running
simple web applications on a local machine, such as might be done when testing
or debugging an application.  It has not been reviewed for security issues,
however, and we strongly recommend that you use a "real" web server for
production use.

For example usage, see the 'if __name__=="__main__"' block at the end of the
module.  See also the BaseHTTPServer module docs for other API information.
�)�BaseHTTPRequestHandler�
HTTPServerN)�
SimpleHandler)�python_implementationz0.2�
WSGIServer�WSGIRequestHandler�demo_app�make_server�WSGIServer/�/� c@seZdZeZdd�ZdS)�
ServerHandlerc	Cs4z"|j�|j�dd�d|j�W5t�|�XdS)Nr�r)r�close�request_handlerZlog_requestZstatus�splitZ
bytes_sent��self�r�-/usr/lib64/python3.8/wsgiref/simple_server.pyr s�zServerHandler.closeN)�__name__�
__module__�__qualname__�software_versionZserver_softwarerrrrrr
sr
c@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)rz7BaseHTTPServer that implements the Python WSGI protocolNcCst�|�|��dS)z.Override server_bind to store the server name.N)r�server_bind�
setup_environrrrrr0s
zWSGIServer.server_bindcCsFi}|_|j|d<d|d<t|j�|d<d|d<d|d<d|d<dS)	NZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PORT��REMOTE_HOST�CONTENT_LENGTHZSCRIPT_NAME)�base_environZserver_name�strZserver_port)r�envrrrr5s

zWSGIServer.setup_environcCs|jS�N��applicationrrrr�get_app?szWSGIServer.get_appcCs
||_dSr"r#)rr$rrr�set_appBszWSGIServer.set_app)	rrr�__doc__r$rrr%r&rrrrr*s
c@s,eZdZdeZdd�Zdd�Zdd�ZdS)	rr
cCsP|jj��}|j|d<|j|d<|j|d<d|jkrH|j�dd�\}}n|jd}}tj	�
|d�|d<||d	<|��}||jd
kr�||d<|jd
|d<|j
�d
�dkr�|j
��|d<n|j
d
|d<|j
�d�}|r�||d<|j
��D]`\}}|�dd���}|��}||k�rq�d||k�r>|d|d|7<q�||d|<q�|S)NZSERVER_PROTOCOLZSERVER_SOFTWAREZREQUEST_METHOD�?rrz
iso-8859-1Z	PATH_INFOZQUERY_STRINGrrZREMOTE_ADDRzcontent-typeZCONTENT_TYPEzcontent-lengthr�-�_ZHTTP_�,)�serverr�copy�request_version�server_version�command�pathr�urllib�parseZunquoteZaddress_stringZclient_addressZheaders�getZget_content_type�items�replace�upper�strip)rr!r1Zquery�hostZlength�k�vrrr�get_environKs8




zWSGIRequestHandler.get_environcCstjSr")�sys�stderrrrrr�
get_stderrpszWSGIRequestHandler.get_stderrcCs�|j�d�|_t|j�dkr<d|_d|_d|_|�d�dS|��sHdSt	|j|j
|��|��dd�}||_
|�|j���dS)zHandle a single HTTP requestiiri�NF)Zmultithread)Zrfile�readlineZraw_requestline�lenZrequestliner.r0Z
send_errorZ
parse_requestr
Zwfiler?r<r�runr,r%)rZhandlerrrr�handless$
�zWSGIRequestHandler.handleN)rrr�__version__r/r<r?rCrrrrrGs%cCsrddlm}|�}td|d�t|d�t|���}|D]\}}t|dt|�|d�q8|ddg�|���d�gS)	Nr)�StringIOzHello world!)�file�=z200 OK)zContent-Typeztext/plain; charset=utf-8zutf-8)�iorE�print�sortedr5�repr�getvalue�encode)�environZstart_responserE�stdout�hr:r;rrrr�s
cCs|||f|�}|�|�|S)zACreate a new WSGI server listening on `host` and `port` for `app`)r&)r9�portZappZserver_classZ
handler_classr,rrrr	�s
�__main__ri@zServing HTTP onrQrz...zhttp://localhost:8000/xyz?abc) r'Zhttp.serverrrr=Zurllib.parser2Zwsgiref.handlersr�platformrrD�__all__r/�versionr�sys_versionrr
rrrr	rZhttpdZsocketZgetsocknameZsarIZ
webbrowser�openZhandle_requestrrrr�<module>s0C
�
	


__pycache__/validate.cpython-38.pyc000064400000034645150327212340013210 0ustar00U

e5d�:�@s�dZdgZddlZddlZddlZe�d�Ze�d�ZGdd�de�Z	dd	�Z
d
d�Zdd�ZGd
d�d�Z
Gdd�d�ZGdd�d�ZGdd�d�ZGdd�d�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdS)'a&
Middleware to check for obedience to the WSGI specification.

Some of the things this checks:

* Signature of the application and start_response (including that
  keyword arguments are not used).

* Environment checks:

  - Environment is a dictionary (and not a subclass).

  - That all the required keys are in the environment: REQUEST_METHOD,
    SERVER_NAME, SERVER_PORT, wsgi.version, wsgi.input, wsgi.errors,
    wsgi.multithread, wsgi.multiprocess, wsgi.run_once

  - That HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH are not in the
    environment (these headers should appear as CONTENT_LENGTH and
    CONTENT_TYPE).

  - Warns if QUERY_STRING is missing, as the cgi module acts
    unpredictably in that case.

  - That CGI-style variables (that don't contain a .) have
    (non-unicode) string values

  - That wsgi.version is a tuple

  - That wsgi.url_scheme is 'http' or 'https' (@@: is this too
    restrictive?)

  - Warns if the REQUEST_METHOD is not known (@@: probably too
    restrictive).

  - That SCRIPT_NAME and PATH_INFO are empty or start with /

  - That at least one of SCRIPT_NAME or PATH_INFO are set.

  - That CONTENT_LENGTH is a positive integer.

  - That SCRIPT_NAME is not '/' (it should be '', and PATH_INFO should
    be '/').

  - That wsgi.input has the methods read, readline, readlines, and
    __iter__

  - That wsgi.errors has the methods flush, write, writelines

* The status is a string, contains a space, starts with an integer,
  and that integer is in range (> 100).

* That the headers is a list (not a subclass, not another kind of
  sequence).

* That the items of the headers are tuples of strings.

* That there is no 'status' header (that is used in CGI, but not in
  WSGI).

* That the headers don't contain newlines or colons, end in _ or -, or
  contain characters codes below 037.

* That Content-Type is given if there is content (CGI often has a
  default content type, but WSGI does not).

* That no Content-Type is given when there is no content (@@: is this
  too restrictive?)

* That the exc_info argument to start_response is a tuple or None.

* That all calls to the writer are with strings, and no other methods
  on the writer are accessed.

* That wsgi.input is used properly:

  - .read() is called with exactly one argument

  - That it returns a string

  - That readline, readlines, and __iter__ return strings

  - That .close() is not called

  - No other methods are provided

* That wsgi.errors is used properly:

  - .write() and .writelines() is called with a string

  - That .close() is not called, and no other methods are provided.

* The response iterator:

  - That it is not a string (it should be a list of a single string; a
    string will work, but perform horribly).

  - That .__next__() returns a string

  - That the iterator is not iterated over until start_response has
    been called (that can signal either a server or application
    error).

  - That .close() is called (doesn't raise exception, only prints to
    sys.stderr, because we only know it isn't called when the object
    is garbage collected).
�	validator�Nz^[a-zA-Z][a-zA-Z0-9\-_]*$z[\000-\037]c@seZdZdZdS)�WSGIWarningz:
    Raised in response to WSGI-spec-related warnings
    N)�__name__�
__module__�__qualname__�__doc__�rr�(/usr/lib64/python3.8/wsgiref/validate.pyrysrcGs|st|��dS�N)�AssertionError)Zcond�argsrrr	�assert_~sr
cCs(t|�tkr|Std�|t|����dS)Nz!{0} must be of type str (got {1}))�type�strr�format�repr)�value�titlerrr	�check_string_type�s
�rcs�fdd�}|S)a�
    When applied between a WSGI server and a WSGI application, this
    middleware will check for WSGI compliancy on a number of levels.
    This middleware does not modify the request or response in any
    way, but will raise an AssertionError if anything seems off
    (except for a failure to close the application iterator, which
    will be printed to stderr -- there's no way to raise an exception
    at that point).
    cs�tt|�dkd�t|d�|\}�t|�g���fdd�}t|d�|d<t|d�|d<�||�}t|dk	oz|dkd	�t|�t|��S)
N�zTwo arguments required�No keyword arguments allowedcs�tt|�dkpt|�dkd|f�t|d�|d}|d}t|�dkrV|d}nd}t|�t|�t||�t|���d�t�|��S)Nr�zInvalid number of arguments: %srr�)r
�len�check_status�
check_headers�check_content_type�check_exc_info�append�WriteWrapper)r�kw�status�headers�exc_info�Zstart_responseZstart_response_startedrr	�start_response_wrapper�s�


z;validator.<locals>.lint_app.<locals>.start_response_wrapper�
wsgi.input�wsgi.errorsFz>The application must return an iterator, if only an empty list)r
r�
check_environ�InputWrapper�ErrorWrapper�check_iterator�IteratorWrapper)rr �environr%�iterator��applicationr$r	�lint_app�s
�zvalidator.<locals>.lint_appr)r0r1rr/r	r�s)c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)r)cCs
||_dSr
)�input)�self�
wsgi_inputrrr	�__init__�szInputWrapper.__init__cGs0tt|�dk�|jj|�}tt|�tk�|S�Nr)r
rr2�readr�bytes�r3r�vrrr	r7�szInputWrapper.readcGs0tt|�dk�|jj|�}tt|�tk�|Sr6)r
rr2�readlinerr8r9rrr	r;�szInputWrapper.readlinecGsJtt|�dk�|jj|�}tt|�tk�|D]}tt|�tk�q0|Sr6)r
rr2�	readlinesr�listr8)r3r�lines�linerrr	r<�szInputWrapper.readlinesccs|��}|sdS|VqdSr
)r;)r3r?rrr	�__iter__�szInputWrapper.__iter__cCstdd�dS)Nrz input.close() must not be called�r
�r3rrr	�close�szInputWrapper.closeN)	rrrr5r7r;r<r@rCrrrr	r)�sr)c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r*cCs
||_dSr
)�errors)r3�wsgi_errorsrrr	r5�szErrorWrapper.__init__cCs tt|�tk�|j�|�dSr
)r
rrrD�write�r3�srrr	rF�szErrorWrapper.writecCs|j��dSr
)rD�flushrBrrr	rI�szErrorWrapper.flushcCs|D]}|�|�qdSr
)rF)r3�seqr?rrr	�
writelines�szErrorWrapper.writelinescCstdd�dS)Nrz!errors.close() must not be calledrArBrrr	rC�szErrorWrapper.closeN)rrrr5rFrIrKrCrrrr	r*�s
r*c@seZdZdd�Zdd�ZdS)rcCs
||_dSr
)�writer)r3Zwsgi_writerrrr	r5�szWriteWrapper.__init__cCstt|�tk�|�|�dSr
)r
rr8rLrGrrr	�__call__�szWriteWrapper.__call__N)rrrr5rMrrrr	r�src@seZdZdd�Zdd�ZdS)�PartialIteratorWrappercCs
||_dSr
�r.)r3�
wsgi_iteratorrrr	r5szPartialIteratorWrapper.__init__cCst|jd�Sr
)r,r.rBrrr	r@szPartialIteratorWrapper.__iter__N)rrrr5r@rrrr	rN�srNc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r,cCs ||_t|�|_d|_||_dS)NF)�original_iterator�iterr.�closed�check_start_response)r3rPrTrrr	r5	s
zIteratorWrapper.__init__cCs|Sr
rrBrrr	r@szIteratorWrapper.__iter__cCsTt|jd�t|j�}t|�tk	r4tdd|f�|jdk	rPt|jd�d|_|S)NzIterator read after closedFz$Iterator yielded non-bytestring (%r)zjThe application returns and we started iterating over its body, but start_response has not yet been called)r
rS�nextr.rr8rT)r3r:rrr	�__next__s�

�zIteratorWrapper.__next__cCs d|_t|jd�r|j��dS)NTrC)rS�hasattrrQrCrBrrr	rCszIteratorWrapper.closecCs"|jstj�d�t|jd�dS)Nz/Iterator garbage collected without being closed)rS�sys�stderrrFr
rBrrr	�__del__#s��zIteratorWrapper.__del__N)rrrr5r@rVrCrZrrrr	r,s
r,cCs�tt|�tkdt|�|f�dD]}t||kd|f�q"dD]"}t||kd||dd�f�q@d|krxt�dt�|��D]:}d	|kr�q�tt||�tkd
|t||�||f�q�tt|d�tkd|df�t|d
dkd|d
�t	|d�t
|d�|ddk�r0t�d|dt�t|�d��pL|d�d�d|d�t|�d��pv|d�d�d|d�|�d��r�tt
|d�dkd|d�|�d��s�td|kd�t|�d�dkd�dS)Nz:Environment is not of the right type: %r (environment: %r))	�REQUEST_METHODZSERVER_NAMEZSERVER_PORT�wsgi.versionr&r'zwsgi.multithreadzwsgi.multiprocessz
wsgi.run_oncez$Environment missing required key: %r)ZHTTP_CONTENT_TYPEZHTTP_CONTENT_LENGTHz8Environment should not have the key: %s (use %s instead)�ZQUERY_STRINGz�QUERY_STRING is not in the WSGI environment; the cgi module will use sys.argv when this variable is missing, so application errors are more likely�.z9Environmental variable %s is not a string: %r (value: %r)r\z#wsgi.version should be a tuple (%r)zwsgi.url_scheme)ZhttpZhttpszwsgi.url_scheme unknown: %rr&r'r[)ZGETZHEADZPOSTZOPTIONSZPATCHZPUTZDELETEZTRACEzUnknown REQUEST_METHOD: %rZSCRIPT_NAME�/z$SCRIPT_NAME doesn't start with /: %rZ	PATH_INFOz"PATH_INFO doesn't start with /: %rZCONTENT_LENGTHrzInvalid CONTENT_LENGTH: %rzgOne of SCRIPT_NAME or PATH_INFO are required (PATH_INFO should at least be '/' if SCRIPT_NAME is empty)zOSCRIPT_NAME cannot be '/'; it should instead be '', and PATH_INFO should be '/')r
r�dict�warnings�warnr�keysr�tuple�check_input�check_errors�get�
startswith�int)r-�keyrrr	r(*sx
���������
�
�
�
�
���r(cCs&dD]}tt||�d||f�qdS)N)r7r;r<r@z-wsgi.input (%r) doesn't have the attribute %s�r
rW)r4�attrrrr	reks
��recCs&dD]}tt||�d||f�qdS)N)rIrFrKz.wsgi.errors (%r) doesn't have the attribute %srk)rErlrrr	rfqs
��rfcCsvt|d�}|�dd�d}tt|�dkd|�t|�}t|dkd|�t|�dksb|dd	krrt�d
|t�dS)N�Statusrrrz)Status codes must be three characters: %r�dzStatus code is invalid: %r�� zjThe status string (%r) should be a three-digit integer followed by a single space and a status explanation)r�splitr
rrirarbr)r!Zstatus_codeZ
status_intrrr	rws
���rcCstt|�tkd|t|�f�|D]�}tt|�tkd|t|�f�tt|�dk�|\}}t|d�}t|d�}t|��dkd|�td|ko�d	|kd
|�tt�|�d|�t|�	d�o�|�	d
�d|�t
�|�r"tdd|t
�|��d�f�q"dS)Nz%Headers (%r) must be of type list: %rz1Individual headers (%r) must be of type tuple: %rr�Header namezHeader valuer!zyThe Status header cannot be used; it conflicts with CGI script, and HTTP status is not given through headers (value: %r).�
�:z,Header names may not contain ':' or '\n': %rzBad header name: %r�-�_z#Names may not end in '-' or '_': %rrz#Bad header value: %r (bad char: %r))r
rr=rdrr�lower�	header_re�search�endswith�bad_header_value_re�group)r"�item�namerrrr	r�s>
��
��

����
�rcCs|t|d�}t|�dd�d�}d}|D]:\}}t|d�}|��dkr&||krRdStdd|�q&||krxtdd|�dS)	Nrmrr)��i0rrzcontent-typezJContent-Type header found in a %s response, which must not return content.z,No Content-Type header found in headers (%s))rrirqrwr
)r!r"�codeZNO_MESSAGE_BODYr~rrrr	r�s

�rcCs*t|dkpt|�tkd|t|�f�dS)Nz exc_info (%r) is not a tuple: %r)r
rrd)r#rrr	r�s�rcCstt|ttf�d�dS)NzwYou should not return a string as your application iterator, instead return a single-item list containing a bytestring.)r
�
isinstancerr8rOrrr	r+�s�r+)r�__all__�rerXra�compilerxr{�Warningrr
rrr)r*rrNr,r(rerfrrrrr+rrrr	�<module>s.j

7#		#A__pycache__/headers.cpython-38.pyc000064400000017116150327212340013024 0ustar00U

e5dn�@s2dZddlZe�d�Zd	dd�ZGdd�d�ZdS)
z�Manage HTTP Response Headers

Much of this module is red-handedly pilfered from email.message in the stdlib,
so portions are Copyright (C) 2001,2002 Python Software Foundation, and were
written by Barry Warsaw.
�Nz[ \(\)<>@,;:\\"/\[\]\?=]�cCsX|dk	rPt|�dkrP|s"t�|�rB|�dd��dd�}d||fSd||fSn|SdS)	z~Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.
    Nr�\z\\�"z\"z%s="%s"z%s=%s)�len�	tspecials�search�replace)Zparam�valueZquote�r
�'/usr/lib64/python3.8/wsgiref/headers.py�_formatparam
src@s�eZdZdZd%dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zd&dd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�ZdS)'�Headersz,Manage a collection of HTTP response headersNcCsP|dk	r|ng}t|�tk	r$td��||_|D]\}}|�|�|�|�q.dS)Nz+Headers must be a list of name/value tuples)�type�list�	TypeError�_headers�_convert_string_type)�selfZheaders�k�vr
r
r�__init__s
zHeaders.__init__cCs&t|�tkr|Std�t|����dS)zConvert/check value type.z1Header names/values must be of type str (got {0})N)r�str�AssertionError�format�repr)rr	r
r
rr)s
�zHeaders._convert_string_typecCs
t|j�S)z9Return the total number of headers, including duplicates.)rr�rr
r
r�__len__0szHeaders.__len__cCs&||=|j�|�|�|�|�f�dS)zSet the value of a header.N)r�appendr)r�name�valr
r
r�__setitem__4s�zHeaders.__setitem__cs0|�������fdd�|jD�|jdd�<dS)zyDelete all occurrences of a header, if present.

        Does *not* raise an exception if the header is missing.
        cs g|]}|d���kr|�qS)r��lower��.0Zkv�rr
r�
<listcomp>@sz'Headers.__delitem__.<locals>.<listcomp>N�rr"r�rrr
r%r�__delitem__:szHeaders.__delitem__cCs
|�|�S)aHGet the first header value for 'name'

        Return None if the header is missing instead of raising an exception.

        Note that if the header appeared multiple times, the first exactly which
        occurrence gets returned is undefined.  Use getall() to get all
        the values matching a header field name.
        ��getr(r
r
r�__getitem__Bs	zHeaders.__getitem__cCs|�|�dk	S)z/Return true if the message contains the header.Nr*r(r
r
r�__contains__MszHeaders.__contains__cs"|�������fdd�|jD�S)aqReturn a list of all the values for the named field.

        These will be sorted in the order they appeared in the original header
        list or were added to this instance, and may contain duplicates.  Any
        fields deleted and re-inserted are always appended to the header list.
        If no fields exist with the given name, returns an empty list.
        cs$g|]}|d���kr|d�qS)rrr!r#r%r
rr&[sz#Headers.get_all.<locals>.<listcomp>r'r(r
r%r�get_allRszHeaders.get_allcCs6|�|���}|jD]\}}|��|kr|Sq|S)z:Get the first header value for 'name', or return 'default'r')rr�defaultrrr
r
rr+^s

zHeaders.getcCsdd�|jD�S)a*Return a list of all the header field names.

        These will be sorted in the order they appeared in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cSsg|]\}}|�qSr
r
�r$rrr
r
rr&osz Headers.keys.<locals>.<listcomp>�rrr
r
r�keysgszHeaders.keyscCsdd�|jD�S)a!Return a list of all header values.

        These will be sorted in the order they appeared in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        cSsg|]\}}|�qSr
r
r0r
r
rr&ysz"Headers.values.<locals>.<listcomp>r1rr
r
r�valuesqszHeaders.valuescCs|jdd�S)aGet all the header fields and values.

        These will be sorted in the order they were in the original header
        list, or were added to this instance, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        Nr1rr
r
r�items{sz
Headers.itemscCsd|jj|jfS)Nz%s(%r))�	__class__�__name__rrr
r
r�__repr__�szHeaders.__repr__cCsd�dd�|jD�ddg�S)zkstr() returns the formatted headers, complete with end line,
        suitable for direct HTTP transmission.z
cSsg|]}d|�qS)z%s: %sr
r#r
r
rr&�sz#Headers.__str__.<locals>.<listcomp>�)�joinrrr
r
r�__str__�szHeaders.__str__cCst|��d�S)Nz
iso-8859-1)r�encoderr
r
r�	__bytes__�szHeaders.__bytes__cCs:|�|�}|dkr2|j�|�|�|�|�f�|S|SdS)z�Return first matching header value for 'name', or 'value'

        If there is no header named 'name', add a new header with name 'name'
        and value 'value'.N)r+rrr)rrr	�resultr
r
r�
setdefault�s
�zHeaders.setdefaultcKs�g}|dk	r |�|�}|�|�|��D]P\}}|�|�}|dkrV|�|�dd��q(|�|�}|�t|�dd�|��q(|j�|�|�d�|�f�dS)afExtended header setting.

        _name is the header field to add.  keyword arguments can be used to set
        additional parameters for the header field, with underscores converted
        to dashes.  Normally the parameter will be added as key="value" unless
        value is None, in which case only the key will be added.

        Example:

        h.add_header('content-disposition', 'attachment', filename='bud.gif')

        Note that unlike the corresponding 'email.message' method, this does
        *not* handle '(charset, language, value)' tuples: all values must be
        strings or None.
        N�_�-z; )rrr4rrrr9)r�_nameZ_valueZ_params�partsrrr
r
r�
add_header�s



zHeaders.add_header)N)N)r6�
__module__�__qualname__�__doc__rrrr r)r,r-r.r+r2r3r4r7r:r<r>rCr
r
r
rr
s$


	



r
)Nr)rF�re�compilerrr
r
r
r
r�<module>s	

__pycache__/simple_server.cpython-38.opt-1.pyc000064400000012217150327212340015224 0ustar00U

e5d3�	@s dZddlmZmZddlZddlZddlmZddl	m
Z
dZddd	d
gZdeZ
e
�dej��dZe
d
eZGdd�de�ZGdd�de�ZGdd�de�Zdd	�Zeefdd
�Zedk�redde��BZej��Zededdedd�ddlZe�d�e��W5QRXdS)a!BaseHTTPServer that implements the Python WSGI protocol (PEP 3333)

This is both an example of how WSGI can be implemented, and a basis for running
simple web applications on a local machine, such as might be done when testing
or debugging an application.  It has not been reviewed for security issues,
however, and we strongly recommend that you use a "real" web server for
production use.

For example usage, see the 'if __name__=="__main__"' block at the end of the
module.  See also the BaseHTTPServer module docs for other API information.
�)�BaseHTTPRequestHandler�
HTTPServerN)�
SimpleHandler)�python_implementationz0.2�
WSGIServer�WSGIRequestHandler�demo_app�make_server�WSGIServer/�/� c@seZdZeZdd�ZdS)�
ServerHandlerc	Cs4z"|j�|j�dd�d|j�W5t�|�XdS)Nr�r)r�close�request_handlerZlog_requestZstatus�splitZ
bytes_sent��self�r�-/usr/lib64/python3.8/wsgiref/simple_server.pyr s�zServerHandler.closeN)�__name__�
__module__�__qualname__�software_versionZserver_softwarerrrrrr
sr
c@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)rz7BaseHTTPServer that implements the Python WSGI protocolNcCst�|�|��dS)z.Override server_bind to store the server name.N)r�server_bind�
setup_environrrrrr0s
zWSGIServer.server_bindcCsFi}|_|j|d<d|d<t|j�|d<d|d<d|d<d|d<dS)	NZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PORT��REMOTE_HOST�CONTENT_LENGTHZSCRIPT_NAME)�base_environZserver_name�strZserver_port)r�envrrrr5s

zWSGIServer.setup_environcCs|jS�N��applicationrrrr�get_app?szWSGIServer.get_appcCs
||_dSr"r#)rr$rrr�set_appBszWSGIServer.set_app)	rrr�__doc__r$rrr%r&rrrrr*s
c@s,eZdZdeZdd�Zdd�Zdd�ZdS)	rr
cCsP|jj��}|j|d<|j|d<|j|d<d|jkrH|j�dd�\}}n|jd}}tj	�
|d�|d<||d	<|��}||jd
kr�||d<|jd
|d<|j
�d
�dkr�|j
��|d<n|j
d
|d<|j
�d�}|r�||d<|j
��D]`\}}|�dd���}|��}||k�rq�d||k�r>|d|d|7<q�||d|<q�|S)NZSERVER_PROTOCOLZSERVER_SOFTWAREZREQUEST_METHOD�?rrz
iso-8859-1Z	PATH_INFOZQUERY_STRINGrrZREMOTE_ADDRzcontent-typeZCONTENT_TYPEzcontent-lengthr�-�_ZHTTP_�,)�serverr�copy�request_version�server_version�command�pathr�urllib�parseZunquoteZaddress_stringZclient_addressZheaders�getZget_content_type�items�replace�upper�strip)rr!r1Zquery�hostZlength�k�vrrr�get_environKs8




zWSGIRequestHandler.get_environcCstjSr")�sys�stderrrrrr�
get_stderrpszWSGIRequestHandler.get_stderrcCs�|j�d�|_t|j�dkr<d|_d|_d|_|�d�dS|��sHdSt	|j|j
|��|��dd�}||_
|�|j���dS)zHandle a single HTTP requestiiri�NF)Zmultithread)Zrfile�readlineZraw_requestline�lenZrequestliner.r0Z
send_errorZ
parse_requestr
Zwfiler?r<r�runr,r%)rZhandlerrrr�handless$
�zWSGIRequestHandler.handleN)rrr�__version__r/r<r?rCrrrrrGs%cCsrddlm}|�}td|d�t|d�t|���}|D]\}}t|dt|�|d�q8|ddg�|���d�gS)	Nr)�StringIOzHello world!)�file�=z200 OK)zContent-Typeztext/plain; charset=utf-8zutf-8)�iorE�print�sortedr5�repr�getvalue�encode)�environZstart_responserE�stdout�hr:r;rrrr�s
cCs|||f|�}|�|�|S)zACreate a new WSGI server listening on `host` and `port` for `app`)r&)r9�portZappZserver_classZ
handler_classr,rrrr	�s
�__main__ri@zServing HTTP onrQrz...zhttp://localhost:8000/xyz?abc) r'Zhttp.serverrrr=Zurllib.parser2Zwsgiref.handlersr�platformrrD�__all__r/�versionr�sys_versionrr
rrrr	rZhttpdZsocketZgetsocknameZsarIZ
webbrowser�openZhandle_requestrrrr�<module>s0C
�
	


__pycache__/util.cpython-38.opt-2.pyc000064400000007403150327212340013324 0ustar00U

e5d��@srddlZddddddgZGdd�d�Zd	d�Zd
d�Zddd�Zd
d�Zdd�ZddddddddhjZ	dd�Z
dS)�N�FileWrapper�guess_scheme�application_uri�request_uri�shift_path_info�setup_testing_defaultsc@s.eZdZddd�Zdd�Zdd�Zdd	�Zd
S)r� cCs"||_||_t|d�r|j|_dS)N�close)�filelike�blksize�hasattrr	)�selfr
r�r�$/usr/lib64/python3.8/wsgiref/util.py�__init__s
zFileWrapper.__init__cCs6ddl}|jdtdd�|j�|j�}|r.|St�dS)NrzXFileWrapper's __getitem__ method ignores 'key' parameter. Use iterator protocol instead.�)�
stacklevel)�warnings�warn�DeprecationWarningr
�readr�
IndexError)r
�keyr�datarrr�__getitem__s�zFileWrapper.__getitem__cCs|S�Nr)r
rrr�__iter__!szFileWrapper.__iter__cCs|j�|j�}|r|St�dSr)r
rr�
StopIteration)r
rrrr�__next__$szFileWrapper.__next__N)r)�__name__�
__module__�__qualname__rrrrrrrrrs

cCs|�d�dkrdSdSdS)NZHTTPS)ZyesZon�1�https�http)�get)�environrrrr*scCs�|dd}ddlm}|�d�r0||d7}nR||d7}|ddkrf|dd	kr�|d
|d7}n|ddkr�|d
|d7}|||�d�p�d
dd�7}|S)N�wsgi.url_schemez://r��quote�	HTTP_HOST�SERVER_NAMEr#�SERVER_PORT�443�:�80�SCRIPT_NAME�/�latin1)�encoding)�urllib.parser)r%)r&�urlr)rrrr2s
TcCspt|�}ddlm}||�dd�ddd�}|�d�sF||d	d�7}n||7}|rl|�d
�rl|d|d
7}|S)Nrr(�	PATH_INFO�z/;=,r2)Zsafer3r0�ZQUERY_STRING�?)rr4r)r%)r&Z
include_queryr5r)�	path_inforrrrFs
cCs�|�dd�}|sdS|�d�}dd�|dd�D�|dd�<|d}|d=|�dd�}t�|d|�}|�d�r~|dd�}|s�|�d�s�|d7}||d<d�|�|d<|d	kr�d}|S)
Nr6r7r1cSsg|]}|r|dkr|�qS)�.r)�.0�prrr�
<listcomp>esz#shift_path_info.<locals>.<listcomp>r8���r0r;)r%�split�	posixpath�normpath�endswith�join)r&r:�
path_parts�nameZscript_namerrrrSs$


cCs�|�dd�|�dd�|�d|d�|�dd�d|kr\d	|kr\|�dd
�|�d	d�|�dd
�|�dd�|�dd�|�dd�ddlm}m}|�d|��|�d|��|�dt|��|ddkr�|�dd�n|ddkr�|�dd�dS)Nr+z	127.0.0.1ZSERVER_PROTOCOLzHTTP/1.0r*ZREQUEST_METHODZGETr0r6r7r1zwsgi.version)r8rz
wsgi.run_oncerzwsgi.multithreadzwsgi.multiprocess)�StringIO�BytesIOz
wsgi.inputzwsgi.errorsr'r$r,r/r#r-)�
setdefault�iorGrHr)r&rGrHrrrr|s&
Z
connectionz
keep-alivezproxy-authenticatezproxy-authorizationZteZtrailersztransfer-encodingZupgradecCst|���Sr)�_hoppish�lower)Zheader_namerrr�
is_hop_by_hop�srM)T)rA�__all__rrrrrr�__contains__rKrMrrrr�<module>s.�

))�__pycache__/validate.cpython-38.opt-2.pyc000064400000025564150327212340014150 0ustar00U

e5d�:�@s�dgZddlZddlZddlZe�d�Ze�d�ZGdd�de�Zdd�Z	d	d
�Z
dd�ZGdd
�d
�ZGdd�d�Z
Gdd�d�ZGdd�d�ZGdd�d�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�ZdS)&�	validator�Nz^[a-zA-Z][a-zA-Z0-9\-_]*$z[\000-\037]c@seZdZdS)�WSGIWarningN)�__name__�
__module__�__qualname__�rr�(/usr/lib64/python3.8/wsgiref/validate.pyrysrcGs|st|��dS�N)�AssertionError)Zcond�argsrrr�assert_~srcCs(t|�tkr|Std�|t|����dS)Nz!{0} must be of type str (got {1}))�type�strr
�format�repr)�value�titlerrr�check_string_type�s
�rcs�fdd�}|S)Ncs�tt|�dkd�t|d�|\}�t|�g���fdd�}t|d�|d<t|d�|d<�||�}t|dk	oz|dkd	�t|�t|��S)
N�zTwo arguments required�No keyword arguments allowedcs�tt|�dkpt|�dkd|f�t|d�|d}|d}t|�dkrV|d}nd}t|�t|�t||�t|���d�t�|��S)Nr�zInvalid number of arguments: %srr�)r�len�check_status�
check_headers�check_content_type�check_exc_info�append�WriteWrapper)r�kw�status�headers�exc_info�Zstart_responseZstart_response_startedrr�start_response_wrapper�s�


z;validator.<locals>.lint_app.<locals>.start_response_wrapper�
wsgi.input�wsgi.errorsFz>The application must return an iterator, if only an empty list)rr�
check_environ�InputWrapper�ErrorWrapper�check_iterator�IteratorWrapper)rr�environr$�iterator��applicationr#r�lint_app�s
�zvalidator.<locals>.lint_appr)r/r0rr.rr�s)c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)r(cCs
||_dSr	)�input)�self�
wsgi_inputrrr�__init__�szInputWrapper.__init__cGs0tt|�dk�|jj|�}tt|�tk�|S�Nr)rrr1�readr
�bytes�r2r�vrrrr6�szInputWrapper.readcGs0tt|�dk�|jj|�}tt|�tk�|Sr5)rrr1�readliner
r7r8rrrr:�szInputWrapper.readlinecGsJtt|�dk�|jj|�}tt|�tk�|D]}tt|�tk�q0|Sr5)rrr1�	readlinesr
�listr7)r2r�lines�linerrrr;�szInputWrapper.readlinesccs|��}|sdS|VqdSr	)r:)r2r>rrr�__iter__�szInputWrapper.__iter__cCstdd�dS)Nrz input.close() must not be called�r�r2rrr�close�szInputWrapper.closeN)	rrrr4r6r:r;r?rBrrrrr(�sr(c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r)cCs
||_dSr	)�errors)r2�wsgi_errorsrrrr4�szErrorWrapper.__init__cCs tt|�tk�|j�|�dSr	)rr
rrC�write�r2�srrrrE�szErrorWrapper.writecCs|j��dSr	)rC�flushrArrrrH�szErrorWrapper.flushcCs|D]}|�|�qdSr	)rE)r2�seqr>rrr�
writelines�szErrorWrapper.writelinescCstdd�dS)Nrz!errors.close() must not be calledr@rArrrrB�szErrorWrapper.closeN)rrrr4rErHrJrBrrrrr)�s
r)c@seZdZdd�Zdd�ZdS)rcCs
||_dSr	)�writer)r2Zwsgi_writerrrrr4�szWriteWrapper.__init__cCstt|�tk�|�|�dSr	)rr
r7rKrFrrr�__call__�szWriteWrapper.__call__N)rrrr4rLrrrrr�src@seZdZdd�Zdd�ZdS)�PartialIteratorWrappercCs
||_dSr	�r-)r2�
wsgi_iteratorrrrr4szPartialIteratorWrapper.__init__cCst|jd�Sr	)r+r-rArrrr?szPartialIteratorWrapper.__iter__N)rrrr4r?rrrrrM�srMc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r+cCs ||_t|�|_d|_||_dS)NF)�original_iterator�iterr-�closed�check_start_response)r2rOrSrrrr4	s
zIteratorWrapper.__init__cCs|Sr	rrArrrr?szIteratorWrapper.__iter__cCsTt|jd�t|j�}t|�tk	r4tdd|f�|jdk	rPt|jd�d|_|S)NzIterator read after closedFz$Iterator yielded non-bytestring (%r)zjThe application returns and we started iterating over its body, but start_response has not yet been called)rrR�nextr-r
r7rS)r2r9rrr�__next__s�

�zIteratorWrapper.__next__cCs d|_t|jd�r|j��dS)NTrB)rR�hasattrrPrBrArrrrBszIteratorWrapper.closecCs"|jstj�d�t|jd�dS)Nz/Iterator garbage collected without being closed)rR�sys�stderrrErrArrr�__del__#s��zIteratorWrapper.__del__N)rrrr4r?rUrBrYrrrrr+s
r+cCs�tt|�tkdt|�|f�dD]}t||kd|f�q"dD]"}t||kd||dd�f�q@d|krxt�dt�|��D]:}d	|kr�q�tt||�tkd
|t||�||f�q�tt|d�tkd|df�t|d
dkd|d
�t	|d�t
|d�|ddk�r0t�d|dt�t|�d��pL|d�d�d|d�t|�d��pv|d�d�d|d�|�d��r�tt
|d�dkd|d�|�d��s�td|kd�t|�d�dkd�dS)Nz:Environment is not of the right type: %r (environment: %r))	�REQUEST_METHODZSERVER_NAMEZSERVER_PORT�wsgi.versionr%r&zwsgi.multithreadzwsgi.multiprocessz
wsgi.run_oncez$Environment missing required key: %r)ZHTTP_CONTENT_TYPEZHTTP_CONTENT_LENGTHz8Environment should not have the key: %s (use %s instead)�ZQUERY_STRINGz�QUERY_STRING is not in the WSGI environment; the cgi module will use sys.argv when this variable is missing, so application errors are more likely�.z9Environmental variable %s is not a string: %r (value: %r)r[z#wsgi.version should be a tuple (%r)zwsgi.url_scheme)ZhttpZhttpszwsgi.url_scheme unknown: %rr%r&rZ)ZGETZHEADZPOSTZOPTIONSZPATCHZPUTZDELETEZTRACEzUnknown REQUEST_METHOD: %rZSCRIPT_NAME�/z$SCRIPT_NAME doesn't start with /: %rZ	PATH_INFOz"PATH_INFO doesn't start with /: %rZCONTENT_LENGTHrzInvalid CONTENT_LENGTH: %rzgOne of SCRIPT_NAME or PATH_INFO are required (PATH_INFO should at least be '/' if SCRIPT_NAME is empty)zOSCRIPT_NAME cannot be '/'; it should instead be '', and PATH_INFO should be '/')rr
�dict�warnings�warnr�keysr�tuple�check_input�check_errors�get�
startswith�int)r,�keyrrrr'*sx
���������
�
�
�
�
���r'cCs&dD]}tt||�d||f�qdS)N)r6r:r;r?z-wsgi.input (%r) doesn't have the attribute %s�rrV)r3�attrrrrrdks
��rdcCs&dD]}tt||�d||f�qdS)N)rHrErJz.wsgi.errors (%r) doesn't have the attribute %srj)rDrkrrrreqs
��recCsvt|d�}|�dd�d}tt|�dkd|�t|�}t|dkd|�t|�dksb|dd	krrt�d
|t�dS)N�Statusrrrz)Status codes must be three characters: %r�dzStatus code is invalid: %r�� zjThe status string (%r) should be a three-digit integer followed by a single space and a status explanation)r�splitrrrhr`rar)r Zstatus_codeZ
status_intrrrrws
���rcCstt|�tkd|t|�f�|D]�}tt|�tkd|t|�f�tt|�dk�|\}}t|d�}t|d�}t|��dkd|�td|ko�d	|kd
|�tt�|�d|�t|�	d�o�|�	d
�d|�t
�|�r"tdd|t
�|��d�f�q"dS)Nz%Headers (%r) must be of type list: %rz1Individual headers (%r) must be of type tuple: %rr�Header namezHeader valuer zyThe Status header cannot be used; it conflicts with CGI script, and HTTP status is not given through headers (value: %r).�
�:z,Header names may not contain ':' or '\n': %rzBad header name: %r�-�_z#Names may not end in '-' or '_': %rrz#Bad header value: %r (bad char: %r))rr
r<rcrr�lower�	header_re�search�endswith�bad_header_value_re�group)r!�item�namerrrrr�s>
��
��

����
�rcCs|t|d�}t|�dd�d�}d}|D]:\}}t|d�}|��dkr&||krRdStdd|�q&||krxtdd|�dS)	Nrlrr)��i0rqzcontent-typezJContent-Type header found in a %s response, which must not return content.z,No Content-Type header found in headers (%s))rrhrprvr)r r!�codeZNO_MESSAGE_BODYr}rrrrr�s

�rcCs*t|dkpt|�tkd|t|�f�dS)Nz exc_info (%r) is not a tuple: %r)rr
rc)r"rrrr�s�rcCstt|ttf�d�dS)NzwYou should not return a string as your application iterator, instead return a single-item list containing a bytestring.)r�
isinstancerr7rNrrrr*�s�r*)�__all__�rerWr`�compilerwrz�Warningrrrrr(r)rrMr+r'rdrerrrrr*rrrr�<module>os,

7#		#A__pycache__/handlers.cpython-38.pyc000064400000040100150327212340013176 0ustar00U

e5d�T�
@sdZddlmZmZmZddlmZddlZddlZddl	Z	dddd	d
dgZ
dd
dddddgZdddddddddddddg
Zdd �Z
d!d"d#d$d%d&d'd(d)d*h
jZd+d,�Zd-d�ZGd.d�d�ZGd/d�de�ZGd0d�de�ZGd1d	�d	e�ZGd2d
�d
e�ZdS)3z/Base classes for server/gateway implementations�)�FileWrapper�guess_scheme�
is_hop_by_hop)�Headers�N�BaseHandler�
SimpleHandler�BaseCGIHandler�
CGIHandler�
IISCGIHandler�read_environZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc
	Cs:t�|�\	}}}}}}}}}	dt||t|||||fS)Nz#%s, %02d %3s %4d %02d:%02d:%02d GMT)�time�gmtime�_weekdayname�
_monthname)
Z	timestampZyearZmonthZdayZhhZmmZssZwd�y�z�r�(/usr/lib64/python3.8/wsgiref/handlers.py�format_date_times�r�SCRIPT_NAME�	PATH_INFOZQUERY_STRINGZREQUEST_METHODZ	AUTH_TYPEZCONTENT_TYPEZCONTENT_LENGTHZHTTPSZREMOTE_USERZREMOTE_IDENTcCs6t|�p4|�d�p4|�d�p4|�d�o4t|dd��S)NZHTTP_ZSSL_Z	REDIRECT_�	)�_is_request�
startswith�_needs_transcode)�krrrrs�rcCs�t��}d}zd�d|�Wntk
r4d}YnXi}tj��D]�\}}t|�r�tjdkr�tj�	dd��
�}|�d�r�|�d��d�}q�|�d	�r�q�|�d
�r�d|kr�|�d��d�}q�|�|d��d�}n|�||��d�}|||<qD|S)z'Read environment, fixing HTTP variables�surrogateescape�zutf-8�replaceZwin32�SERVER_SOFTWAREzmicrosoft-iis/�
iso-8859-1zapache/zsimplehttp/zpython/3)
�sys�getfilesystemencoding�encode�LookupError�os�environ�itemsr�platform�get�lowerr�decode)�encZescr'r�vZsoftwarerrrr"s0

	

��
c@s"eZdZdZdZdZdZdZdZdZ	dZ
e�Ze
ZeZdZdZdgZd	ZdZZdZdZd
Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zd;dd�Z dd�Z!dd�Z"dd�Z#dd �Z$d!d"�Z%d#d$�Z&d%d&�Z'd'd(�Z(d)d*�Z)d+d,�Z*d-d.�Z+d/d0�Z,d1d2�Z-d3d4�Z.d5d6�Z/d7d8�Z0d9d:�Z1dS)<rz+Manage the invocation of a WSGI application)rrTFz1.0Nz500 Internal Server Error)zContent-Typez
text/plains;A server error occurred.  Please contact the administrator.rc
Cstz$|��||j|j�|_|��WnJtttfk
r@YdSz|��Wn|�	��YnXYnXdS)zInvoke the applicationN)
�
setup_environr'�start_response�result�finish_response�ConnectionAbortedError�BrokenPipeError�ConnectionResetError�handle_error�close)�selfZapplicationrrr�run�szBaseHandler.runcCs�|j��}|_|��|��|d<|��|d<|j|d<|j|d<|��|d<|j	|d<|j
|d<|jdk	rx|j|d	<|jr�|j
r�|�d
|j
�dS)z&Set up the environment for one requestz
wsgi.inputzwsgi.errorszwsgi.versionz
wsgi.run_oncezwsgi.url_schemezwsgi.multithreadzwsgi.multiprocessNzwsgi.file_wrapperr )�
os_environ�copyr'�add_cgi_vars�	get_stdin�
get_stderr�wsgi_version�
wsgi_run_once�
get_scheme�wsgi_multithread�wsgi_multiprocess�wsgi_file_wrapper�
origin_server�server_software�
setdefault)r8�envrrrr/�s





zBaseHandler.setup_environcCsdz2|��r|��s0|jD]}|�|�q|��Wn$t|jd�rP|j���Yn
X|��dS)a>Send any iterable data, then close self and the iterable

        Subclasses intended for use in asynchronous servers will
        want to redefine this method, such that it sets up callbacks
        in the event loop to iterate over the data, and to call
        'self.close()' once the response is finished.
        r7N)�result_is_file�sendfiler1�write�finish_content�hasattrr7�r8�datarrrr2�s

zBaseHandler.finish_responsecCs
t|j�S)z Return the URL scheme being used)rr'�r8rrrrA�szBaseHandler.get_schemec
CsJzt|j�}Wntttfk
r(YnX|dkrFt|j�|jd<dSdS)z@Compute Content-Length or switch to chunked encoding if possibler�Content-LengthN)�lenr1�	TypeError�AttributeError�NotImplementedError�str�
bytes_sent�headers)r8Zblocksrrr�set_content_length�szBaseHandler.set_content_lengthcCsd|jkr|��dS)zqMake any necessary header changes or defaults

        Subclasses can extend this to add other defaults.
        rQN)rXrYrPrrr�cleanup_headers�s
zBaseHandler.cleanup_headerscCs�|r2z$|jr&|d|d��|d��W5d}Xn|jdk	rDtd��||_|�|�|_|�|d�}t|�dksvtd��|dd	���s�td
��|d	dks�td��|D]>\}}|�|d
�}|�|d�}t	|�r�td|�d|�d���q�|j
S)z4'start_response()' callable as specified by PEP 3333Nrr�zHeaders already set!ZStatus�z$Status must be at least 4 characters�z(Status message must begin w/3-digit code� z+Status message must have a space after codezHeader namezHeader valuezHop-by-hop header, 'z: z', not allowed)�headers_sent�with_tracebackrX�AssertionError�status�
headers_class�_convert_string_typerR�isdigitrrK)r8rbrX�exc_info�name�valrrrr0�s(

�zBaseHandler.start_responsecCs(t|�tkr|Std�|t|����dS)zConvert/check value type.z!{0} must be of type str (got {1})N)�typerVra�format�repr)r8�value�titlerrrrd�s
�z BaseHandler._convert_string_typecCs�|jrx|��r�|�d|j|jf�d��d|jkrP|�dtt����d��|j	r�d|jkr�|�d|j	�d��n|�d|j�d��dS)	z6Transmit version/status/date/server, via self._write()zHTTP/%s %s
r!ZDatez
Date: %s
ZServerzServer: %s
zStatus: %s
N)
rE�client_is_modern�_write�http_versionrbr$rXrr
rFrPrrr�
send_preambles
�zBaseHandler.send_preamblecCsft|�tkstd��|js$td��n,|js>t|�|_|��n|jt|�7_|�|�|�	�dS)z+'write()' callable as specified by PEP 3333z)write() argument must be a bytes instancezwrite() before start_response()N)
ri�bytesrarbr_rRrW�send_headersro�_flushrNrrrrKs�



zBaseHandler.writecCsdS)aPlatform-specific file transmission

        Override this method in subclasses to support platform-specific
        file transmission.  It is only called if the application's
        return iterable ('self.result') is an instance of
        'self.wsgi_file_wrapper'.

        This method should return a true value if it was able to actually
        transmit the wrapped file-like object using a platform-specific
        approach.  It should return a false value if normal iteration
        should be used instead.  An exception can be raised to indicate
        that transmission was attempted, but failed.

        NOTE: this method should call 'self.send_headers()' if
        'self.headers_sent' is false and it is going to attempt direct
        transmission of the file.
        FrrPrrrrJ)szBaseHandler.sendfilecCs"|js|j�dd�|��ndS)z.Ensure headers and content have both been sentrQ�0N)r_rXrGrsrPrrrrL>s
zBaseHandler.finish_contentc	CsFzt|jd�r|j��W5d|_|_|_|_d|_d|_XdS)z�Close the iterable (if needed) and reset all instance vars

        Subclasses may want to also drop the client connection.
        NrFr7)r1rXrbr'rWr_rMr7rPrrrr7HszBaseHandler.closecCs8|��d|_|jr|��r4|��|�t|j��dS)z1Transmit headers to the client, via self._write()TN)rZr_rErnrqrorrrXrPrrrrsUs
zBaseHandler.send_headerscCs|j}|dk	ot|j|�S)z@True if 'self.result' is an instance of 'self.wsgi_file_wrapper'N)rD�
isinstancer1)r8�wrapperrrrrI^szBaseHandler.result_is_filecCs|jd��dkS)z,True if client can accept status and headersZSERVER_PROTOCOLzHTTP/0.9)r'�upperrPrrrrndszBaseHandler.client_is_moderncCsJz>ddlm}|��}||d|d|d|j|�|��W5d}XdS)z�Log the 'exc_info' tuple in the server log

        Subclasses may override to retarget the output or change its format.
        Nr)�print_exceptionrr[)�	tracebackryr>�traceback_limit�flush)r8rfry�stderrrrr�
log_exceptionis�zBaseHandler.log_exceptioncCs2|�t���|js.|�|j|j�|_|��dS)z>Log current error, and send error output to client if possibleN)	r~r"rfr_�error_outputr'r0r1r2rPrrrr6yszBaseHandler.handle_errorcCs$||j|jdd�t���|jgS)aZWSGI mini-app to create error output

        By default, this just uses the 'error_status', 'error_headers',
        and 'error_body' attributes to generate an output page.  It can
        be overridden in a subclass to dynamically generate diagnostics,
        choose an appropriate message for the user's preferred language, etc.

        Note, however, that it's not recommended from a security perspective to
        spit out diagnostics to any old user; ideally, you should have to do
        something special to enable diagnostic output, which is why we don't
        include any here!
        N)�error_status�
error_headersr"rf�
error_body)r8r'r0rrrr�s
zBaseHandler.error_outputcCst�dS)aOverride in subclass to buffer data for send to client

        It's okay if this method actually transmits the data; BaseHandler
        just separates write and flush operations for greater efficiency
        when the underlying system actually has such a distinction.
        N�rUrNrrrro�szBaseHandler._writecCst�dS)z�Override in subclass to force sending of recent '_write()' calls

        It's okay if this method is a no-op (i.e., if '_write()' actually
        sends the data.
        Nr�rPrrrrt�szBaseHandler._flushcCst�dS)z4Override in subclass to return suitable 'wsgi.input'Nr�rPrrrr=�szBaseHandler.get_stdincCst�dS)z5Override in subclass to return suitable 'wsgi.errors'Nr�rPrrrr>�szBaseHandler.get_stderrcCst�dS)z>Override in subclass to insert CGI variables in 'self.environ'Nr�rPrrrr<�szBaseHandler.add_cgi_vars)N)2�__name__�
__module__�__qualname__�__doc__r?rBrCr@rErprFrr:rrDrrcr{r�r�r�rbr1r_rXrWr9r/r2rArYrZr0rdrqrKrJrLr7rsrIrnr~r6rrortr=r>r<rrrrr^sV



		c@sBeZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)raqHandler that's just initialized with streams, environment, etc.

    This handler subclass is intended for synchronous HTTP/1.0 origin servers,
    and handles sending the entire response output, given the correct inputs.

    Usage::

        handler = SimpleHandler(
            inp,out,err,env, multithread=False, multiprocess=True
        )
        handler.run(app)TFcCs(||_||_||_||_||_||_dS�N)�stdin�stdoutr}�base_envrBrC)r8r�r�r}r'�multithread�multiprocessrrr�__init__�szSimpleHandler.__init__cCs|jSr�)r�rPrrrr=�szSimpleHandler.get_stdincCs|jSr�)r}rPrrrr>�szSimpleHandler.get_stderrcCs|j�|j�dSr�)r'�updater�rPrrrr<�szSimpleHandler.add_cgi_varscCs^|j�|�}|dks |t|�kr$dSddlm}|dt�||d�}|sLqZ|j�|�}q:dS)Nr)�warnz9SimpleHandler.stdout.write() should not do partial writes)r�rKrR�warningsr��DeprecationWarning)r8rOr1r�rrrro�s�zSimpleHandler._writecCs|j��|jj|_dSr�)r�r|rtrPrrrrt�s
zSimpleHandler._flushN)TF)
r�r�r�r�r�r=r>r<rortrrrrr�s
�


c@seZdZdZdZdS)r	a�CGI-like systems using input/output/error streams and environ mapping

    Usage::

        handler = BaseCGIHandler(inp,out,err,env)
        handler.run(app)

    This handler class is useful for gateway protocols like ReadyExec and
    FastCGI, that have usable input/output/error streams and an environment
    mapping.  It's also the base class for CGIHandler, which just uses
    sys.stdin, os.environ, and so on.

    The constructor also takes keyword arguments 'multithread' and
    'multiprocess' (defaulting to 'True' and 'False' respectively) to control
    the configuration sent to the application.  It sets 'origin_server' to
    False (to enable CGI-like output), and assumes that 'wsgi.run_once' is
    False.
    FN)r�r�r�r�rErrrrr	�sc@s eZdZdZdZiZdd�ZdS)r
a�CGI-based invocation via sys.stdin/stdout/stderr and os.environ

    Usage::

        CGIHandler().run(app)

    The difference between this class and BaseCGIHandler is that it always
    uses 'wsgi.run_once' of 'True', 'wsgi.multithread' of 'False', and
    'wsgi.multiprocess' of 'True'.  It does not take any initialization
    parameters, but always uses 'sys.stdin', 'os.environ', and friends.

    If you need to override any of these parameters, use BaseCGIHandler
    instead.
    Tc	Cs(tj|tjjtjjtjt�ddd�dS)NFT�r�r�)r	r�r"r��bufferr�r}rrPrrrr�s�zCGIHandler.__init__N�r�r�r�r�r@r:r�rrrrr
�sc@s eZdZdZdZiZdd�ZdS)raCGI-based invocation with workaround for IIS path bug

    This handler should be used in preference to CGIHandler when deploying on
    Microsoft IIS without having set the config allowPathInfo option (IIS>=7)
    or metabase allowPathInfoForScriptMappings (IIS<7).
    Tc	Csjt�}|�dd�}|�dd�}|d�|d�rD|t|�d�|d<tj|tjjtj	jtj
|ddd�dS)Nrrr�/FTr�)rr*rrRr	r�r"r�r�r�r})r8r'�pathZscriptrrrr�2s�zIISCGIHandler.__init__Nr�rrrrrs)r��utilrrrrXrr"r&r
�__all__rrr�__contains__rrrrrr	r
rrrrr�<module>s\���<V2__pycache__/validate.cpython-38.opt-1.pyc000064400000034645150327212340014147 0ustar00U

e5d�:�@s�dZdgZddlZddlZddlZe�d�Ze�d�ZGdd�de�Z	dd	�Z
d
d�Zdd�ZGd
d�d�Z
Gdd�d�ZGdd�d�ZGdd�d�ZGdd�d�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdS)'a&
Middleware to check for obedience to the WSGI specification.

Some of the things this checks:

* Signature of the application and start_response (including that
  keyword arguments are not used).

* Environment checks:

  - Environment is a dictionary (and not a subclass).

  - That all the required keys are in the environment: REQUEST_METHOD,
    SERVER_NAME, SERVER_PORT, wsgi.version, wsgi.input, wsgi.errors,
    wsgi.multithread, wsgi.multiprocess, wsgi.run_once

  - That HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH are not in the
    environment (these headers should appear as CONTENT_LENGTH and
    CONTENT_TYPE).

  - Warns if QUERY_STRING is missing, as the cgi module acts
    unpredictably in that case.

  - That CGI-style variables (that don't contain a .) have
    (non-unicode) string values

  - That wsgi.version is a tuple

  - That wsgi.url_scheme is 'http' or 'https' (@@: is this too
    restrictive?)

  - Warns if the REQUEST_METHOD is not known (@@: probably too
    restrictive).

  - That SCRIPT_NAME and PATH_INFO are empty or start with /

  - That at least one of SCRIPT_NAME or PATH_INFO are set.

  - That CONTENT_LENGTH is a positive integer.

  - That SCRIPT_NAME is not '/' (it should be '', and PATH_INFO should
    be '/').

  - That wsgi.input has the methods read, readline, readlines, and
    __iter__

  - That wsgi.errors has the methods flush, write, writelines

* The status is a string, contains a space, starts with an integer,
  and that integer is in range (> 100).

* That the headers is a list (not a subclass, not another kind of
  sequence).

* That the items of the headers are tuples of strings.

* That there is no 'status' header (that is used in CGI, but not in
  WSGI).

* That the headers don't contain newlines or colons, end in _ or -, or
  contain characters codes below 037.

* That Content-Type is given if there is content (CGI often has a
  default content type, but WSGI does not).

* That no Content-Type is given when there is no content (@@: is this
  too restrictive?)

* That the exc_info argument to start_response is a tuple or None.

* That all calls to the writer are with strings, and no other methods
  on the writer are accessed.

* That wsgi.input is used properly:

  - .read() is called with exactly one argument

  - That it returns a string

  - That readline, readlines, and __iter__ return strings

  - That .close() is not called

  - No other methods are provided

* That wsgi.errors is used properly:

  - .write() and .writelines() is called with a string

  - That .close() is not called, and no other methods are provided.

* The response iterator:

  - That it is not a string (it should be a list of a single string; a
    string will work, but perform horribly).

  - That .__next__() returns a string

  - That the iterator is not iterated over until start_response has
    been called (that can signal either a server or application
    error).

  - That .close() is called (doesn't raise exception, only prints to
    sys.stderr, because we only know it isn't called when the object
    is garbage collected).
�	validator�Nz^[a-zA-Z][a-zA-Z0-9\-_]*$z[\000-\037]c@seZdZdZdS)�WSGIWarningz:
    Raised in response to WSGI-spec-related warnings
    N)�__name__�
__module__�__qualname__�__doc__�rr�(/usr/lib64/python3.8/wsgiref/validate.pyrysrcGs|st|��dS�N)�AssertionError)Zcond�argsrrr	�assert_~sr
cCs(t|�tkr|Std�|t|����dS)Nz!{0} must be of type str (got {1}))�type�strr�format�repr)�value�titlerrr	�check_string_type�s
�rcs�fdd�}|S)a�
    When applied between a WSGI server and a WSGI application, this
    middleware will check for WSGI compliancy on a number of levels.
    This middleware does not modify the request or response in any
    way, but will raise an AssertionError if anything seems off
    (except for a failure to close the application iterator, which
    will be printed to stderr -- there's no way to raise an exception
    at that point).
    cs�tt|�dkd�t|d�|\}�t|�g���fdd�}t|d�|d<t|d�|d<�||�}t|dk	oz|dkd	�t|�t|��S)
N�zTwo arguments required�No keyword arguments allowedcs�tt|�dkpt|�dkd|f�t|d�|d}|d}t|�dkrV|d}nd}t|�t|�t||�t|���d�t�|��S)Nr�zInvalid number of arguments: %srr�)r
�len�check_status�
check_headers�check_content_type�check_exc_info�append�WriteWrapper)r�kw�status�headers�exc_info�Zstart_responseZstart_response_startedrr	�start_response_wrapper�s�


z;validator.<locals>.lint_app.<locals>.start_response_wrapper�
wsgi.input�wsgi.errorsFz>The application must return an iterator, if only an empty list)r
r�
check_environ�InputWrapper�ErrorWrapper�check_iterator�IteratorWrapper)rr �environr%�iterator��applicationr$r	�lint_app�s
�zvalidator.<locals>.lint_appr)r0r1rr/r	r�s)c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)r)cCs
||_dSr
)�input)�self�
wsgi_inputrrr	�__init__�szInputWrapper.__init__cGs0tt|�dk�|jj|�}tt|�tk�|S�Nr)r
rr2�readr�bytes�r3r�vrrr	r7�szInputWrapper.readcGs0tt|�dk�|jj|�}tt|�tk�|Sr6)r
rr2�readlinerr8r9rrr	r;�szInputWrapper.readlinecGsJtt|�dk�|jj|�}tt|�tk�|D]}tt|�tk�q0|Sr6)r
rr2�	readlinesr�listr8)r3r�lines�linerrr	r<�szInputWrapper.readlinesccs|��}|sdS|VqdSr
)r;)r3r?rrr	�__iter__�szInputWrapper.__iter__cCstdd�dS)Nrz input.close() must not be called�r
�r3rrr	�close�szInputWrapper.closeN)	rrrr5r7r;r<r@rCrrrr	r)�sr)c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r*cCs
||_dSr
)�errors)r3�wsgi_errorsrrr	r5�szErrorWrapper.__init__cCs tt|�tk�|j�|�dSr
)r
rrrD�write�r3�srrr	rF�szErrorWrapper.writecCs|j��dSr
)rD�flushrBrrr	rI�szErrorWrapper.flushcCs|D]}|�|�qdSr
)rF)r3�seqr?rrr	�
writelines�szErrorWrapper.writelinescCstdd�dS)Nrz!errors.close() must not be calledrArBrrr	rC�szErrorWrapper.closeN)rrrr5rFrIrKrCrrrr	r*�s
r*c@seZdZdd�Zdd�ZdS)rcCs
||_dSr
)�writer)r3Zwsgi_writerrrr	r5�szWriteWrapper.__init__cCstt|�tk�|�|�dSr
)r
rr8rLrGrrr	�__call__�szWriteWrapper.__call__N)rrrr5rMrrrr	r�src@seZdZdd�Zdd�ZdS)�PartialIteratorWrappercCs
||_dSr
�r.)r3�
wsgi_iteratorrrr	r5szPartialIteratorWrapper.__init__cCst|jd�Sr
)r,r.rBrrr	r@szPartialIteratorWrapper.__iter__N)rrrr5r@rrrr	rN�srNc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)r,cCs ||_t|�|_d|_||_dS)NF)�original_iterator�iterr.�closed�check_start_response)r3rPrTrrr	r5	s
zIteratorWrapper.__init__cCs|Sr
rrBrrr	r@szIteratorWrapper.__iter__cCsTt|jd�t|j�}t|�tk	r4tdd|f�|jdk	rPt|jd�d|_|S)NzIterator read after closedFz$Iterator yielded non-bytestring (%r)zjThe application returns and we started iterating over its body, but start_response has not yet been called)r
rS�nextr.rr8rT)r3r:rrr	�__next__s�

�zIteratorWrapper.__next__cCs d|_t|jd�r|j��dS)NTrC)rS�hasattrrQrCrBrrr	rCszIteratorWrapper.closecCs"|jstj�d�t|jd�dS)Nz/Iterator garbage collected without being closed)rS�sys�stderrrFr
rBrrr	�__del__#s��zIteratorWrapper.__del__N)rrrr5r@rVrCrZrrrr	r,s
r,cCs�tt|�tkdt|�|f�dD]}t||kd|f�q"dD]"}t||kd||dd�f�q@d|krxt�dt�|��D]:}d	|kr�q�tt||�tkd
|t||�||f�q�tt|d�tkd|df�t|d
dkd|d
�t	|d�t
|d�|ddk�r0t�d|dt�t|�d��pL|d�d�d|d�t|�d��pv|d�d�d|d�|�d��r�tt
|d�dkd|d�|�d��s�td|kd�t|�d�dkd�dS)Nz:Environment is not of the right type: %r (environment: %r))	�REQUEST_METHODZSERVER_NAMEZSERVER_PORT�wsgi.versionr&r'zwsgi.multithreadzwsgi.multiprocessz
wsgi.run_oncez$Environment missing required key: %r)ZHTTP_CONTENT_TYPEZHTTP_CONTENT_LENGTHz8Environment should not have the key: %s (use %s instead)�ZQUERY_STRINGz�QUERY_STRING is not in the WSGI environment; the cgi module will use sys.argv when this variable is missing, so application errors are more likely�.z9Environmental variable %s is not a string: %r (value: %r)r\z#wsgi.version should be a tuple (%r)zwsgi.url_scheme)ZhttpZhttpszwsgi.url_scheme unknown: %rr&r'r[)ZGETZHEADZPOSTZOPTIONSZPATCHZPUTZDELETEZTRACEzUnknown REQUEST_METHOD: %rZSCRIPT_NAME�/z$SCRIPT_NAME doesn't start with /: %rZ	PATH_INFOz"PATH_INFO doesn't start with /: %rZCONTENT_LENGTHrzInvalid CONTENT_LENGTH: %rzgOne of SCRIPT_NAME or PATH_INFO are required (PATH_INFO should at least be '/' if SCRIPT_NAME is empty)zOSCRIPT_NAME cannot be '/'; it should instead be '', and PATH_INFO should be '/')r
r�dict�warnings�warnr�keysr�tuple�check_input�check_errors�get�
startswith�int)r-�keyrrr	r(*sx
���������
�
�
�
�
���r(cCs&dD]}tt||�d||f�qdS)N)r7r;r<r@z-wsgi.input (%r) doesn't have the attribute %s�r
rW)r4�attrrrr	reks
��recCs&dD]}tt||�d||f�qdS)N)rIrFrKz.wsgi.errors (%r) doesn't have the attribute %srk)rErlrrr	rfqs
��rfcCsvt|d�}|�dd�d}tt|�dkd|�t|�}t|dkd|�t|�dksb|dd	krrt�d
|t�dS)N�Statusrrrz)Status codes must be three characters: %r�dzStatus code is invalid: %r�� zjThe status string (%r) should be a three-digit integer followed by a single space and a status explanation)r�splitr
rrirarbr)r!Zstatus_codeZ
status_intrrr	rws
���rcCstt|�tkd|t|�f�|D]�}tt|�tkd|t|�f�tt|�dk�|\}}t|d�}t|d�}t|��dkd|�td|ko�d	|kd
|�tt�|�d|�t|�	d�o�|�	d
�d|�t
�|�r"tdd|t
�|��d�f�q"dS)Nz%Headers (%r) must be of type list: %rz1Individual headers (%r) must be of type tuple: %rr�Header namezHeader valuer!zyThe Status header cannot be used; it conflicts with CGI script, and HTTP status is not given through headers (value: %r).�
�:z,Header names may not contain ':' or '\n': %rzBad header name: %r�-�_z#Names may not end in '-' or '_': %rrz#Bad header value: %r (bad char: %r))r
rr=rdrr�lower�	header_re�search�endswith�bad_header_value_re�group)r"�item�namerrrr	r�s>
��
��

����
�rcCs|t|d�}t|�dd�d�}d}|D]:\}}t|d�}|��dkr&||krRdStdd|�q&||krxtdd|�dS)	Nrmrr)��i0rrzcontent-typezJContent-Type header found in a %s response, which must not return content.z,No Content-Type header found in headers (%s))rrirqrwr
)r!r"�codeZNO_MESSAGE_BODYr~rrrr	r�s

�rcCs*t|dkpt|�tkd|t|�f�dS)Nz exc_info (%r) is not a tuple: %r)r
rrd)r#rrr	r�s�rcCstt|ttf�d�dS)NzwYou should not return a string as your application iterator, instead return a single-item list containing a bytestring.)r
�
isinstancerr8rOrrr	r+�s�r+)r�__all__�rerXra�compilerxr{�Warningrr
rrr)r*rrNr,r(rerfrrrrr+rrrr	�<module>s.j

7#		#A__pycache__/__init__.cpython-38.pyc000064400000001326150327212340013144 0ustar00U

e5dK�@sdZdS)aDwsgiref -- a WSGI (PEP 3333) Reference Library

Current Contents:

* util -- Miscellaneous useful functions and wrappers

* headers -- Manage response headers

* handlers -- base classes for server/gateway implementations

* simple_server -- a simple BaseHTTPServer that supports WSGI

* validate -- validation wrapper that sits between an app and a server
  to detect errors in either

To-Do:

* cgi_gateway -- Run WSGI apps under CGI (pending a deployment standard)

* cgi_wrapper -- Run CGI apps under WSGI

* router -- a simple middleware component that handles URL traversal
N)�__doc__�rr�(/usr/lib64/python3.8/wsgiref/__init__.py�<module>�