Display a warning for using option --ignore-stdin when request fails with content present in stdin
landure opened this issue · 0 comments
landure commented
Checklist
- [ X] I've searched for similar issues.
- [ X] I'm using the latest version of HTTPie.
Running environment
- Ubuntu 22.04.3 LTS Jammy
- bash 5.1-6ubuntu1
- HTTPie 3.2.1 from
https://packages.httpie.io/deb
- jq
(jq @ GitHub) 1.6-2.1ubuntu3.
Minimal reproduction code and steps
Install the software:
sudo apt install 'miller' jq'
The error occurred when interrogating Gandi Public API.
Set Gandi API Key:
gandi_api_key="<Gandi API key>"
Query Gandi API for all domains mailboxes:
while read -r 'domain'; do
command https --body "https://api.gandi.net/v5/email/mailboxes/${domain}" \
"Authorization: Apikey ${gandi_api_key}" 'per_page==250'
done < <( command https --body 'https://api.gandi.net/v5/domain/domains' \
"Authorization: Apikey ${gandi_api_key}" 'per_page==250' |
command jq '.[].fqdn' |
command tr --delete '"' )
Current result
The first loop output is:
Bad Request
Expected result
The expected result:
Bad Request
Warning: stdin contents detected. Retry with --ignore-stdin option.
Additional information, screenshots, or code examples
I've found the final answer in #1017 and when using --debug option.
HTTPie should be able to detect if stdin contents come from a pipe or are for xargs or a bash loop.
In any case, displaying a warning when a request fails with stdin content could prevent users some headaches.