Repository navigation
Merge repeated curl -d/--data options in Request.from_curl() - #7728
Merged
AdrianAtZyte merged 1 commit intoJul 20, 2026
Merged
Conversation
curl merges repeated -d/--data/--data-raw options into a single request
body joined with "&" (e.g. `curl -d a=1 -d b=2` sends `a=1&b=2`). scrapy's
DataAction kept only the last value, silently dropping the earlier ones, so
`Request.from_curl("curl -d a=1 -d b=2 ...")` produced a body of just `b=2`.
Accumulate the values with "&" to match curl. -H/--header and -b/--cookie
already accumulate via action="append"; -d was the only repeatable data flag
that didn't.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7728 +/- ##
=======================================
Coverage 95.31% 95.31%
=======================================
Files 164 164
Lines 13023 13026 +3
Branches 1688 1689 +1
=======================================
+ Hits 12413 12416 +3
Misses 419 419
Partials 191 191
|
wRAR
approved these changes
Jul 17, 2026
AdrianAtZyte
approved these changes
Jul 20, 2026
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.
No linked issue — found while reading
scrapy/utils/curl.py.Summary
Request.from_curl()silently drops all but the last-d/--data/--data-rawvalue when a curl command repeats them.curl merges repeated data options into a single body joined with
&. From the curl man page (-d, --data):But scrapy's
DataActionuses a single-value action, so it keeps only the last one:Verified against real curl 7.87. This bites anyone converting a hand-written or tool-generated curl command with multiple
-dflags into a Scrapy request.Fix
Accumulate repeated values with
&inDataAction, mirroring curl. This covers the whole class:-H/--headerand-b/--cookiealready accumulate viaaction="append";-d/--data/--data-raw(all mapped toDataAction) was the only repeatable data flag that didn't.The per-value
$-prefix stripping (from$'...'shell quoting) still applies to each option before the merge.Tests
Adds three cases to
tests/test_utils_curl.py— repeated-d, mixed-d/--data/--data-raw, and repeated with$-prefix quoting. They fail on the current code and pass with the fix; the fulltest_utils_curl.pysuite passes andruffcheck + format are clean.