MCPcopy Index your code
hub / github.com/RustPython/RustPython / getheader

Method getheader

Lib/http/client.py:750–768  ·  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

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

Calls 5

ResponseNotReadyClass · 0.85
isinstanceFunction · 0.85
hasattrFunction · 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