Repository navigation
Guard Net::HTTPHeader#content_length spec by net-http version - #1404
Merged
andrykonchin merged 1 commit intoOct 23, 2026
Merged
Conversation
Strict Content-Length parsing came with net-http 0.10.0, not with a Ruby version: Ruby 4.0.x ships net-http 0.9.1 by default, but updating the gem on it brings the strict behavior. Guard on Net::HTTP::VERSION instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Thank you! |
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.
The strict Content-Length parsing came from net-http 0.10.0 (ruby/net-http@23e859e92, ruby/net-http#324), not from a Ruby release. On Ruby 4.0 with net-http updated to 0.10.0, the
ruby_version_is ""..."4.1"spec runs against the strict implementation and raisesNet::HTTPHeaderSyntaxError: wrong Content-Length format: 123valid.This PR guards both examples with
version_is Net::HTTP::VERSION, "0.10.0".Why not a Ruby version guard
No Ruby version boundary matches this behavior change:
lib/net/http.rb, which still parses leniently. Ruby first ships 0.10.0 on master (4.1).gems/4.0.0/gems/net-http-0.10.0installed on top of the default 0.9.1, so the strict implementation was loaded even thoughRUBY_VERSIONwas 4.0.9.ruby_version_is "4.0.9", a stock 4.0.9 with net-http 0.9.1 would fail the strict example. With the current"4.1", any 4.0.x with an updated net-http fails the lenient example.Guarding on
Net::HTTP::VERSIONfollows the existing convention for default gems that are commonly updated separately from Ruby:BigDecimal::VERSION(10 guards),OpenSSL::VERSION(2) andStringIO::VERSION(1) inlibrary/.Seen in RubyInstaller2 CI on 4.0.9: https://github.com/oneclick/rubyinstaller2/actions/runs/39949977572/job/120434751465
Checked with
mspec-run library/net-http/httpheader/content_length_spec.rb:🤖 Generated with Claude Code