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

Handle an HTTP Response with a Content-type but no body. #530

Merged
merged 1 commit into from
May 16, 2017

Conversation

robdimarco
Copy link

In c46663d a change was made to clean up the encode_with_ruby_encoding method.

Previously, the force_encoding method was always called and then there was a rescue that would just return the body. If a request had a nil body, the rescue made sure that a nil value (the original body) would be returned.

After c46663d, if a response had a nil body, an error would be thrown when parsing the response.

This PR includes a spec that reproduces the error and a fix that adds a nil check to make sure we do not call force_encoding on nil. If the body is nil, we will return nil. This matches the previous behavior.

This fixes an error that was being raised when the request specified a content type and an encoding
BUT the body of the response is nil.

In that situation, we just want to return nil.
@jnunemaker
Copy link
Owner

Thanks!

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