Repository navigation
Conversation
type_params and body encoding both read that parameter. A header such as "text/html; charset" used to raise NoMethodError.
type_params called strip on the missing half of a parameter, so a header such as "text/html; charset" raised NoMethodError. An empty value is still kept.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #375.
Net::HTTPHeader#type_paramssplit each parameter on=and calledstripon both halves. A parameter with no=, such asContent-Type: text/html; charset, left the valueniland raisedNoMethodError.Net::HTTPResponse#detect_encodinguses the same method when body encoding is enabled, so reading the body raised it too.NoMethodErroris not aNet::HTTPerror, so the rescues documented for protocol failures do not catch it.A parameter without
=is now skipped.charset=still records an empty value, and a later parameter on the same header is still parsed.Before this change,
type_paramsontext/html; charsetraisedundefined method 'strip' for nil. After it, that header returns{},text/html; charset; boundary=fooreturns{"boundary"=>"foo"}, andtext/html; charset=returns{"charset"=>""}.ruby -Ilib:test/lib -rhelper test/net/http/test_httpheader.rb: 41 tests, 205 assertions, 0 failures.ruby -Ilib:test/lib -rhelper test/net/http/test_httpresponse.rb: 50 tests, 110 assertions, 0 failures. The new example reads a body withbody_encoding = trueandContent-Type: text/plain; charset.