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)
| 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 | |
| 217 | def _read_headers(fp, max_headers): |
| 218 | """Reads potential header lines into a list from a file pointer. |