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

Method getheader

Lib/http/client.py:753–771  ·  view source on GitHub ↗

Returns the value of the header matching *name*. If there are multiple matching headers, the values are combined into a single string separated by commas and spaces. If no matching header is found, returns *default* or None if the *default* is not specified.

(self, name, default=None)

Source from the content-addressed store, hash-verified

751 return self.fp.fileno()
752
753 def getheader(self, name, default=None):
754 '''Returns the value of the header matching *name*.
755
756 If there are multiple matching headers, the values are
757 combined into a single string separated by commas and spaces.
758
759 If no matching header is found, returns *default* or None if
760 the *default* is not specified.
761
762 If the headers are unknown, raises http.client.ResponseNotReady.
763
764 '''
765 if self.headers is None:
766 raise ResponseNotReady()
767 headers = self.headers.get_all(name) or default
768 if isinstance(headers, str) or not hasattr(headers, '__iter__'):
769 return headers
770 else:
771 return ', '.join(headers)
772
773 def getheaders(self):
774 """Return list of (header, value) tuples."""

Calls 3

ResponseNotReadyClass · 0.85
get_allMethod · 0.45
joinMethod · 0.45

Tested by 15

test_parse_all_octetsMethod · 0.76
test_response_headersMethod · 0.76
test_get_cssMethod · 0.64
parse_responseMethod · 0.64
test_epipeMethod · 0.64
test_getting_headerMethod · 0.64