kurtmckee / feedparser

Parse feeds in Python
https://feedparser.readthedocs.io/en/latest/
Other
1.89k stars 336 forks source link

Make feedparser accepts caseinsensitive headers #423

Closed smallfish06 closed 6 months ago

smallfish06 commented 6 months ago

Currently FeedParserDict's headers type is dict. https://github.com/kurtmckee/feedparser/blob/0af72dc07bcd3c6e74dfc40a913a346f8a6fa45e/feedparser/api.py#L195-L200

But while assigning response_headers which is type of CaseInsensitiveDict to headers it act like dict. https://github.com/kurtmckee/feedparser/blob/0af72dc07bcd3c6e74dfc40a913a346f8a6fa45e/feedparser/api.py#L224-L227

If this acts like this it's hard to parse Content-Type

HTTP/1.1 200 OK
Connection: keep-alive
Date: Sat, 30 Dec 2023 09:20:21 GMT
Content-Type: text/xml; charset=UTF-8
Transfer-Encoding: chunked

If it is expected behavior, how can I modify Content-Type overriding Http requester?

FYI: requests headers type is CaseInsensitiveDict https://github.com/psf/requests/blob/72eccc8dd8b7c272e520f22b0256386c80864e94/src/requests/adapters.py#L293-L314