getsentry / responses

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

Addressed bug where recording requests does not save headers to file. Closes #715 #720

Closed TheJacobWalters closed 3 weeks ago

TheJacobWalters commented 1 month ago

I have made a working solution here.

I would welcome feedback on how I can improve this.

I left some comments in my code explaining the main issue I was overcoming. Which is that the headers field of the Request is a unique data structure called ValueView. Writing this data structure to a YAML file created a lot of strange "Tag" artifacts in the file. Therefore I decided that I would need to coerce the data structure into a standard type of Dict. That was harder than I expected and I ended up just parsing the string representation of the ValueView into a Dict. There is probably a better way to do this but I don't know what it is yet.

When this MR is ready to move off of Draft, I can remove those comments.