def http_error_302(self, req, fp, code, msg, headers): infourl = urllib_response.addinfourl(fp, headers, headers["Location"]) try: infourl.status = code except AttributeError: pass infourl.code = code log.debug("Redirecting with code %d to: %s", code, headers["Location"]) return infourl
def fopen(req, *args, **kwargs): url = req.get_full_url() p = urllib_parse.urlparse(url) try: res = ressources[p.path] if isinstance(res, Exception): raise res elif isinstance(res, bytes): return urllib_response.addinfourl(BytesIO(res), {"content-length": len(res)}, url, 200) else: return res except LookupError: raise U.urllib_error.HTTPError(url, 404, "Not Found", {}, None)
def http_error_302(self, req, fp, code, msg, headers): infourl = addinfourl(fp, headers, req.get_full_url()) infourl.status = code infourl.code = code return infourl
def http_error_302(self, req, fp, code, msg, headers): infourl = urllib_response.addinfourl(fp, headers, headers["Location"]) infourl.status = code infourl.code = code return infourl
def http_error_302(self, req, fp, code, msg, headers): infourl = urllib_response.addinfourl(fp, headers, headers["Location"]) infourl.status = code infourl.code = code log.debug("Redirecting to: %s", headers["Location"]) return infourl