getsentry / responses

A utility for mocking out the Python Requests library.
Apache License 2.0
4.1k stars 351 forks source link

recorder: use a case-insensitive HTTP headers check #728

Open ptalbert opened 1 month ago

ptalbert commented 1 month ago

_recorder._remove_default_headers() does a case-sensitive check for HTTP header field names are case insensitive. The result is that for example, a lower-case 'content-type' field will not be removed. Later, when _add_from_file tries to load the data using RequestsMock.add(), a RuntimeError exception will be raised when it finds the 'content_type' kwarg was passed and 'content-type' is in the 'headers' kwargs.

Fix this by simply having _remove_default_headers() do a case-insensitive check.