(self, sock, method="GET", scheme="http", path="/",
                 protocol=(1, 1), qs="", headers=None, server=None)
initializes x; see x.__class__.__doc__ for signature
initializes x; see x.__class__.__doc__ for signature
initializes x ; see x . __class__ . __doc__ for signature
def __init__(self, sock, method="GET", scheme="http", path="/",
                 protocol=(1, 1), qs="", headers=None, server=None):
        "initializes x; see x.__class__.__doc__ for signature"

        self.sock = sock
        self.method = method
        self.scheme = scheme or Request.scheme
        self.path = path
        self.protocol = protocol
        self.qs = qs
        self.print_debug = getattr(server, "display_banner", False)

        self.headers = headers or Headers()
        self.server = server

        self.cookie = SimpleCookie()

        if sock is not None:
            name = sock.getpeername()
            if name is not None:
                self.remote = Host(*name)
            else:
                name = sock.getsockname()
                self.remote = Host(name, "", name)

        cookie = self.headers.get("Cookie")
        if cookie is not None:
            self.cookie.load(cookie)

        self.body = BytesIO()

        if self.server is not None:
            self.local = Host(self.server.host, self.server.port)

        try:
            host = self.headers["Host"]
            if ":" in host:
                parts = host.split(":", 1)
                host = parts[0]
                port = int(parts[1])
            else:
                port = 443 if self.scheme == "https" else 80
        except KeyError:
            host = self.local.name or self.local.ip
            port = getattr(self.server, "port")

        self.host = host
        self.port = port

        base = "{0:s}://{1:s}{2:s}/".format(
            self.scheme,
            self.host,
            ":{0:d}".format(self.port) if self.port not in (80, 443) else ""
        )
        self.base = parse_url(base)

        url = "{0:s}{1:s}{2:s}".format(
            base,
            self.path,
            "?{0:s}".format(self.qs) if self.qs else ""
        )
        self.uri = parse_url(url)
        self.uri.sanitize()
def __init__ ( self , sock , method = "GET" , scheme = "http" , path = "/" , protocol = ( 1 , 1 ) , qs = "" , headers = None , server = None ) : self . sock = sock self . method = method self . scheme = scheme or Request . scheme self . path = path self . protocol = protocol self . qs = qs self . print_debug = getattr ( server , "display_banner" , False ) self . headers = headers or Headers ( ) self . server = server self . cookie = SimpleCookie ( ) if sock is not None : name = sock . getpeername ( ) if name is not None : self . remote = Host ( * name ) else : name = sock . getsockname ( ) self . remote = Host ( name , "" , name ) cookie = self . headers . get ( "Cookie" ) if cookie is not None : self . cookie . load ( cookie ) self . body = BytesIO ( ) if self . server is not None : self . local = Host ( self . server . host , self . server . port ) try : host = self . headers [ "Host" ] if ":" in host : parts = host . split ( ":" , 1 ) host = parts [ 0 ] port = int ( parts [ 1 ] ) else : port = 443 if self . scheme == "https" else 80 except KeyError : host = self . local . name or self . local . ip port = getattr ( self . server , "port" ) self . host = host self . port = port base = "{0:s}://{1:s}{2:s}/" . format ( self . scheme , self . host , ":{0:d}" . format ( self . port ) if self . port not in ( 80 , 443 ) else "" ) self . base = parse_url ( base ) url = "{0:s}{1:s}{2:s}" . format ( base , self . path , "?{0:s}" . format ( self . qs ) if self . qs else "" ) self . uri = parse_url ( url ) self . uri . sanitize ( )