MCPcopy Index your code
hub / github.com/python/cpython / HTTPError

Class HTTPError

Lib/urllib/error.py:35–67  ·  view source on GitHub ↗

Raised when HTTP error occurs, but also acts like non-error return

Source from the content-addressed store, hash-verified

33
34
35class HTTPError(URLError, urllib.response.addinfourl):
36 """Raised when HTTP error occurs, but also acts like non-error return"""
37 __super_init = urllib.response.addinfourl.__init__
38
39 def __init__(self, url, code, msg, hdrs, fp):
40 self.code = code
41 self.msg = msg
42 self.hdrs = hdrs
43 self.fp = fp
44 self.filename = url
45 if fp is None:
46 fp = io.BytesIO()
47 self.__super_init(fp, hdrs, url, code)
48
49 def __str__(self):
50 return 'HTTP Error %s: %s' % (self.code, self.msg)
51
52 def __repr__(self):
53 return '<HTTPError %s: %r>' % (self.code, self.msg)
54
55 # since URLError specifies a .reason attribute, HTTPError should also
56 # provide this attribute. See issue13211 for discussion.
57 @property
58 def reason(self):
59 return self.msg
60
61 @property
62 def headers(self):
63 return self.hdrs
64
65 @headers.setter
66 def headers(self, headers):
67 self.hdrs = headers
68
69
70class ContentTooShortError(URLError):

Callers 4

http_error_defaultMethod · 0.90
redirect_requestMethod · 0.90
http_error_302Method · 0.90
http_error_auth_reqedMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…