Skip to content

feat: expand curl data file support#1355

Merged
k1LoW merged 9 commits intok1LoW:mainfrom
yoRyuuuuu:support-data-file-operator
Nov 22, 2025
Merged

feat: expand curl data file support#1355
k1LoW merged 9 commits intok1LoW:mainfrom
yoRyuuuuu:support-data-file-operator

Conversation

@yoRyuuuuu
Copy link

Description

This PR implements part of #1296

Approach

expandCurlDataFiles recognizes the @file syntax in data parameters and expands its content.

It supports both separated parameters (-d @file, --data @file, etc.) and attached parameters (-d@file, --data=@file, etc.).

Testing

Added unit tests for expandCurlDataFiles.

Example run

We generated a runbook from the curl command below and confirmed that the @file payload was expanded as exptected.

$ ./runn new -- curl -X PUT https://httpbin.org/put \
  -H "Content-Type: application/atom+xml" \
  -d '@atom-feed.xml' > runbook.yaml

$ ./runn run runbook.yaml --debug
Run "req" on "Generated by `runn new`".steps[0]
-----START HTTP REQUEST-----
PUT /put HTTP/1.1
Host: httpbin.org
Content-Type: application/atom+xml

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>runn test feed</title>
  <subtitle>Sample Atom feed used for integration tests</subtitle>
</feed>

-----END HTTP REQUEST-----
-----START HTTP RESPONSE-----
HTTP/2.0 200 OK
Content-Length: 610
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Fri, 07 Nov 2025 14:59:25 GMT
Server: gunicorn/19.9.0

{
  "args": {},
  "data": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<feed xmlns=\"http://www.w3.org/2005/Atom\">\n  <title>runn test feed</title>\n  <subtitle>Sample Atom feed used for integration tests</subtitle>\n</feed>\n",
  "files": {},
  "form": {},
  "headers": {
    "Accept-Encoding": "gzip",
    "Content-Length": "189",
    "Content-Type": "application/atom+xml",
    "Host": "httpbin.org",
    "User-Agent": "Go-http-client/2.0",
    "X-Amzn-Trace-Id": "Root=1-690e094b-68e0cb5d258533262e5ecf56"
  },
  "json": null,
  "origin": "114.149.78.44",
  "url": "https://httpbin.org/put"
}

-----END HTTP RESPONSE-----
.

1 scenario, 0 skipped, 0 failures

atom-feed.xml

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>runn test feed</title>
  <subtitle>Sample Atom feed used for integration tests</subtitle>
</feed>

Notes

--data-urlencode support is still out of scope.
If you think --data-urlencode should be covered as well, please let me know and I'll tackle it in a follow-up PR.

@yoRyuuuuu yoRyuuuuu marked this pull request as ready for review November 15, 2025 14:38
@k1LoW k1LoW added enhancement New feature or request minor labels Nov 16, 2025
@k1LoW
Copy link
Owner

k1LoW commented Nov 16, 2025

@yoRyuuuuu GERAT WORK!!!!

@k1LoW k1LoW added tagpr:minor and removed minor labels Nov 17, 2025
@k1LoW
Copy link
Owner

k1LoW commented Nov 17, 2025

@yoRyuuuuu

I have a consultation.

After merging this implementation, is it okay for me to backport it to https://github.com/k1LoW/curlreq?
This would likely fall under curlreq's responsibilities within runn.

@yoRyuuuuu
Copy link
Author

@k1LoW

Thanks for the review!

Yes, it's okay to backport this to curlreq after this PR is merged.

@k1LoW k1LoW merged commit adf4ae6 into k1LoW:main Nov 22, 2025
7 checks passed
@github-actions github-actions bot mentioned this pull request Nov 20, 2025
k1LoW added a commit to k1LoW/curlreq that referenced this pull request Nov 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request tagpr:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants