Repository navigation
Make the Patron adapter work with Patron 1.0 - #1142
Merged
Merged
Conversation
Patron 1.0 moves Patron::Response.new to keyword arguments and only keeps the positional form behind a deprecation shim that goes away in 1.1. Pick the form from Patron::Response#initialize's parameters so that 0.x keeps the positional call and 1.0 gets keywords without a warning. The spec helper passed Session#request a braced options Hash, which 1.0 deprecates the same way; keywords work on both lines. See toland/patron#209 Co-Authored-By: Claude Fable 5.1 <[email protected]>
2 of 3 tasks
bblimke
added a commit
that referenced
this pull request
Nov 18, 2026
#1147 overrode Session#request to catch a GET with a file, which meant copying Patron's check for when it downloads and its handling of the old positional options Hash. Patron's deprecation warning for that Hash then pointed at the adapter rather than the caller, and two positional Hashes were accepted where Patron raises ArgumentError. Override the private Session#download instead, which Patron 1.1 calls with the request already built. handle_request, download and stream now share one method that records the request, finds the stub and refuses the request when real connections are not allowed, so the three cannot drift apart. Callbacks for a streamed request now run before the block, for stubbed and real requests alike, as the Net::HTTP adapter does. Previously they were skipped when the block exited early with break, return or an exception, which Patron expects for event streams. Build the header data in one place for the response and the transfer stats, and decide once at load time whether Patron::Response.new takes keyword arguments (#1142). Add specs for an unstubbed and a real get_file, header and query matching on a streamed request, and blocks that break or raise. Document both PRs in the CHANGELOG.
Owner
|
Thank you @julik! This is released in 3.35.0. |
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.
Patron 1.0 (toland/patron#208, not released yet) moves
Patron::Response.newto keyword arguments. The adapter builds every stubbed response with the six positional arguments, and since the gemspec admits any patron>= 0.4.18, a plainbundle update patronwill land people on 1.0 with the old call. 1.0 ships a shim that keeps the positional form working, but it warnsPatron::Response.new with positional arguments is deprecated and will be removed in Patron 1.1once per process, and once the shim is gone in 1.1 every stubbed request raisesArgumentError.The adapter now asks
Patron::Response#initializewhetherurlis a required keyword and picks the form from that, so 0.x keeps getting the positional call it always got and 1.0 gets keywords with no warning. Detecting by capability rather than by version string also keeps it honest against the Patron git branch and any backport. The spec helper had the same problem one level up, passingSession#requestits options as a braced Hash, which 1.0 deprecates the same way; passing them as keywords works on both lines since Ruby folds them into the trailingoptions = {}on 0.x.I ran
spec/acceptance/patronon patron 0.14.0 and on the 1.0 branch: 327 examples pass on each, the only failures being the tennet_connectexamples that need httpstat.us, which was not answering from here. The Patron side of this is tracked in toland/patron#209.🤖 Generated with Claude Code