getsentry / responses

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

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

Open ptalbert opened 4 months ago

ptalbert commented 4 months 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.

andrew-womeldorf-smar commented 2 months ago

This should also resolve #724