(self, req, fp, code, msg, headers, newurl)
return Request(newurl,
                       headers=newheaders,
                       origin_req_host=req.origin_req_host,
                       unverifiable=True)
Return a Request or None in response to a redirect.

        This is called by the http_error_30x methods when a
        redirection response is received.  If a redirection should
        take place, return a new Request to allow http_error_30x to
        perform the redirect.  Otherwise, raise HTTPError if no-one
        else should try to handle this url.  Return None if you can't
        but another Handler might.
Return a Request or None in response to a redirect.
Return a Request or None in response to a redirect .
def redirect_request(self, req, fp, code, msg, headers, newurl):
        """Return a Request or None in response to a redirect.

        This is called by the http_error_30x methods when a
        redirection response is received.  If a redirection should
        take place, return a new Request to allow http_error_30x to
        perform the redirect.  Otherwise, raise HTTPError if no-one
        else should try to handle this url.  Return None if you can't
        but another Handler might.
        """
        m = req.get_method()
        if (not (code in (301, 302, 303, 307) and m in ("GET", "HEAD")
            or code in (301, 302, 303) and m == "POST")):
            raise HTTPError(req.full_url, code, msg, headers, fp)

        # Strictly (according to RFC 2616), 301 or 302 in response to
        # a POST MUST NOT cause a redirection without confirmation
        # from the user (of urllib.request, in this case).  In practice,
        # essentially all clients do redirect in this case, so we do
        # the same.

        # Be conciliant with URIs containing a space.  This is mainly
        # redundant with the more complete encoding done in http_error_302(),
        # but it is kept for compatibility with other callers.
        newurl = newurl.replace(' ', '%20')

        CONTENT_HEADERS = ("content-length", "content-type")
        newheaders = {k: v for k, v in req.headers.items()
                      if k.lower() not in CONTENT_HEADERS}
        return Request(newurl,
                       headers=newheaders,
                       origin_req_host=req.origin_req_host,
                       unverifiable=True)
def redirect_request ( self , req , fp , code , msg , headers , newurl ) : m = req . get_method ( ) if ( not ( code in ( 301 , 302 , 303 , 307 ) and m in ( "GET" , "HEAD" ) or code in ( 301 , 302 , 303 ) and m == "POST" ) ) : raise HTTPError ( req . full_url , code , msg , headers , fp ) # Strictly (according to RFC 2616), 301 or 302 in response to # a POST MUST NOT cause a redirection without confirmation # from the user (of urllib.request, in this case).  In practice, # essentially all clients do redirect in this case, so we do # the same. # Be conciliant with URIs containing a space.  This is mainly # redundant with the more complete encoding done in http_error_302(), # but it is kept for compatibility with other callers. newurl = newurl . replace ( ' ' , '%20' ) CONTENT_HEADERS = ( "content-length" , "content-type" ) newheaders = { k : v for k , v in req . headers . items ( ) if k . lower ( ) not in CONTENT_HEADERS } return Request ( newurl , headers = newheaders , origin_req_host = req . origin_req_host , unverifiable = True )