Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Interaction to record HTTP headers and status codes #78

Conversation

elliottwilliams
Copy link

I just started using this library today, but I think I hit a small bug in Interaction: I was unable to save the status code and response headers when recording. Here's what I found:

When finished recording, Session.persist calls down to Interaction.dictionary, which checks if response is a HTTPURLResponse. If it is, it records the headers and status code for the response:

if let httpResponse = response as? HTTPURLResponse { 

However, this is checking if the response is a DVR.HTTPURLResponse, not a Foundation.HTTPURLResponse. Since DVR.HTTPURLResponse is only get initialized from cassette dictionaries, this condition should never be true.

I changed HTTPURLResponse to Foundation.HTTPURLResponse and was able to record status code / headers successfully.

Testing

Confirmed that this doesn't affect existing tests.

When finished recording, `Session.persist` calls down to
`Interaction.dictionary`. This getter checks if `response` is a
`HTTPURLResponse`, in which case it records the headers and status code
for the response. However, due to ambiguous namespacing it was checking
if the response was a `DVR.HTTPURLResponse`, not a
`Foundation.HTTPURLResponse`, meaning that recorded HTTP fields would
never be recorded.
@sethhoward
Copy link
Contributor

Still an issue, but been done.
#75

@elliottwilliams
Copy link
Author

Got it, thanks for merging #75!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants