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

Method getallmatchingheaders

Lib/http/client.py:194–215  ·  view source on GitHub ↗

Find all header lines matching a given header name. Look through the list of headers and find all lines matching a given header name (and their continuation lines). A list of the lines is returned, without interpretation. If the header does not occur, an empty list

(self, name)

Source from the content-addressed store, hash-verified

192 # properly defined, it will be kept for backwards compatibility reasons.
193
194 def getallmatchingheaders(self, name):
195 """Find all header lines matching a given header name.
196
197 Look through the list of headers and find all lines matching a given
198 header name (and their continuation lines). A list of the lines is
199 returned, without interpretation. If the header does not occur, an
200 empty list is returned. If the header occurs multiple times, all
201 occurrences are returned. Case is not important in the header name.
202
203 """
204 name = name.lower() + ':'
205 n = len(name)
206 lst = []
207 hit = 0
208 for line in self.keys():
209 if line[:n].lower() == name:
210 hit = 1
211 elif not line[:1].isspace():
212 hit = 0
213 if hit:
214 lst.append(line)
215 return lst
216
217def _read_headers(fp, max_headers):
218 """Reads potential header lines into a list from a file pointer.

Callers

nothing calls this directly

Calls 4

isspaceMethod · 0.80
lowerMethod · 0.45
keysMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected