Lines Matching refs:headers
39 headers, e.g. a User-Agent.
168 context manager and has the properties url, headers, and status.
175 headers as it is specified in the documentation for HTTPResponse.
242 headers = fp.info()
244 # Just return the local path and the "headers" for file://
247 return os.path.normpath(path), headers
258 result = filename, headers
263 if "content-length" in headers:
264 size = int(headers["Content-Length"])
319 def __init__(self, url, data=None, headers={},
323 self.headers = {}
328 for key, value in headers.items():
403 self.headers[key.capitalize()] = val
410 return (header_name in self.headers or
414 return self.headers.get(
419 self.headers.pop(header_name, None)
423 hdrs = {**self.unredirected_hdrs, **self.headers}
518 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method())
653 def redirect_request(self, req, fp, code, msg, headers, newurl):
666 raise HTTPError(req.full_url, code, msg, headers, fp)
680 newheaders = {k: v for k, v in req.headers.items()
683 headers=newheaders,
691 def http_error_302(self, req, fp, code, msg, headers):
692 # Some servers (incorrectly) return multiple Location headers
694 if "location" in headers:
695 newurl = headers["location"]
696 elif "uri" in headers:
697 newurl = headers["uri"]
711 headers, fp)
728 new = self.redirect_request(req, fp, code, msg, headers, newurl)
739 self.inf_msg + msg, headers, fp)
986 def http_error_auth_reqed(self, authreq, host, req, headers):
989 headers = headers.get_all(authreq)
990 if not headers:
995 for header in headers:
1054 def http_error_401(self, req, fp, code, msg, headers):
1057 url, req, headers)
1065 def http_error_407(self, req, fp, code, msg, headers):
1072 authority, req, headers)
1103 def http_error_auth_reqed(self, auth_header, host, req, headers):
1104 authreq = headers.get(auth_header, None)
1112 headers, None)
1129 if req.headers.get(self.auth_header, None) == auth_val:
1236 def http_error_401(self, req, fp, code, msg, headers):
1239 host, req, headers)
1249 def http_error_407(self, req, fp, code, msg, headers):
1252 host, req, headers)
1320 headers = dict(req.unredirected_hdrs)
1321 headers.update({k: v for k, v in req.headers.items()
1322 if k not in headers})
1333 headers["Connection"] = "close"
1334 headers = {name.title(): val for name, val in headers.items()}
1339 if proxy_auth_hdr in headers:
1340 tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr]
1343 del headers[proxy_auth_hdr]
1344 h.set_tunnel(req._tunnel_host, headers=tunnel_headers)
1348 h.request(req.get_method(), req.selector, req.data, headers,
1366 # with .headers, because urllib clients expect the response to
1369 # .headers.
1509 headers = email.message_from_string(
1520 return addinfourl(open(localfile, 'rb'), headers, origurl)
1573 headers = ""
1576 headers += "Content-type: %s\n" % mtype
1578 headers += "Content-length: %d\n" % retrlen
1579 headers = email.message_from_string(headers)
1580 return addinfourl(fp, headers, req.full_url)
1666 headers = email.message_from_string("Content-type: %s\nContent-length: %d\n" %
1669 return addinfourl(io.BytesIO(data), headers, url)
1725 # haven't got the logic to check expiration headers
1764 filename, headers = self.tempcache[fullurl]
1766 return addinfourl(fp, headers, fullurl)
1807 """retrieve(url) returns (filename, headers) for a local object
1808 or (tempfilename, headers) for a remote object."""
1823 headers = fp.info()
1836 result = filename, headers
1843 if "content-length" in headers:
1844 size = int(headers["Content-Length"])
1925 headers = {}
1927 headers["Proxy-Authorization"] = "Basic %s" % proxy_auth
1929 headers["Authorization"] = "Basic %s" % auth
1931 headers["Host"] = realhost
1936 headers["Connection"] = "close"
1939 headers[header] = value
1942 headers["Content-Type"] = "application/x-www-form-urlencoded"
1943 http_conn.request("POST", selector, data, headers)
1945 http_conn.request("GET", selector, headers=headers)
1967 def http_error(self, url, fp, errcode, errmsg, headers, data=None):
1977 result = method(url, fp, errcode, errmsg, headers)
1979 result = method(url, fp, errcode, errmsg, headers, data)
1981 return self.http_error_default(url, fp, errcode, errmsg, headers)
1983 def http_error_default(self, url, fp, errcode, errmsg, headers):
1986 raise HTTPError(url, errcode, errmsg, headers, None)
2020 headers = email.message_from_string(
2027 return addinfourl(open(localname, 'rb'), headers, urlfile)
2036 return addinfourl(open(localname, 'rb'), headers, urlfile)
2087 headers = ""
2089 headers += "Content-Type: %s\n" % mtype
2091 headers += "Content-Length: %d\n" % retrlen
2092 headers = email.message_from_string(headers)
2093 return addinfourl(fp, headers, "ftp:" + url)
2133 headers = email.message_from_string(msg)
2136 return addinfourl(f, headers, url)
2148 def http_error_default(self, url, fp, errcode, errmsg, headers):
2150 return addinfourl(fp, headers, "http:" + url, errcode)
2152 def http_error_302(self, url, fp, errcode, errmsg, headers, data=None):
2163 headers)
2165 headers, data)
2170 def redirect_internal(self, url, fp, errcode, errmsg, headers, data):
2171 if 'location' in headers:
2172 newurl = headers['location']
2173 elif 'uri' in headers:
2174 newurl = headers['uri']
2194 headers, fp)
2198 def http_error_301(self, url, fp, errcode, errmsg, headers, data=None):
2200 return self.http_error_302(url, fp, errcode, errmsg, headers, data)
2202 def http_error_303(self, url, fp, errcode, errmsg, headers, data=None):
2204 return self.http_error_302(url, fp, errcode, errmsg, headers, data)
2206 def http_error_307(self, url, fp, errcode, errmsg, headers, data=None):
2209 return self.http_error_302(url, fp, errcode, errmsg, headers, data)
2211 return self.http_error_default(url, fp, errcode, errmsg, headers)
2213 def http_error_308(self, url, fp, errcode, errmsg, headers, data=None):
2216 return self.http_error_301(url, fp, errcode, errmsg, headers, data)
2218 return self.http_error_default(url, fp, errcode, errmsg, headers)
2220 def http_error_401(self, url, fp, errcode, errmsg, headers, data=None,
2224 if 'www-authenticate' not in headers:
2226 errcode, errmsg, headers)
2227 stuff = headers['www-authenticate']
2231 errcode, errmsg, headers)
2235 errcode, errmsg, headers)
2238 headers)
2245 def http_error_407(self, url, fp, errcode, errmsg, headers, data=None,
2249 if 'proxy-authenticate' not in headers:
2251 errcode, errmsg, headers)
2252 stuff = headers['proxy-authenticate']
2256 errcode, errmsg, headers)
2260 errcode, errmsg, headers)
2263 headers)