New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to ignore stdin data #150
Comments
This error happens when HTTPie's
|
I'm not redirecting STDIN at all. Here's a bit more context in the script:
(and then I parse the 'subnet' file, and go on to do other things) What I MIGHT be doing is intermixing form-fields with http-headers. However, I couldn't get that to work right either (some combination of pushing the form data through STDIN, and headers as parameters... or as headers and form data through STDIN, or whatever). |
I see, the problem is that in the loop context HTTPie inherits its You should be able to work it around by changing HTTPie's
|
Wow. That works. I had NO idea that the inner statements of a shell loop inherit the stdin of the surrounding loop. Thank you for the help... I'm not sure I would have found that on my own. (Now I'm curious why (I'm assuming all SH derived shells) made that design choice... ) |
I think there should be an option to disable the reading of |
This is very confusing, and goes against httpie being able to work anywhere. Using such a command inside a bash loop is a very common application. Httpie should not complain when key/value is given and it receives stdin: instead letting key/value dominate. |
That maybe is intuitive to you, but to many others the exact opposite is far more intuitive. Because tooling should not try to guess, it is far better to raise an error and provide you an escape hatch if you feel you know better, which this does. |
I ran into this issue when using httpie inside of a function passed to GNU parallel: function call_api {
local FOO=`http --json --auth $TOKEN: post $HOST/api/foo name="Ţẽṧẗ" < /dev/tty | python3 -c "import json,sys;obj=json.load(sys.stdin);print(obj['result']['id']);"`
[…]
http --download --auth $TOKEN: GET $HOST/api/bla > /dev/tty
}
export -f call_api
export HOST=…
export TOKEN=…
parallel --env HOST --env TOKEN ::: call_api call_api call_api call_api call_api Thanks to the above comment the parallel function invocation works now. Leaving this comment here for future reference 😊 |
For future reference, there now is a CLI argument
|
Encountered this while using |
I tried redirecting stdin to null |
@NightMachinary you want to use the $ echo 'this STDIN data is ignored' | http --ignore-stdin POST httpbin.org/post hello=world |
@jakubroztocil I know that, I am saying if |
@NightMachinary you cannot eliminate $ echo ignored data | http httpbin.org/anything 0<&- https://superuser.com/questions/813472/how-do-i-close-stdin-in-a-shell-script |
@NightMachinary and redirecting $ http httpbin.org/anything < /dev/null This still invokes HTTPie with an open & redirected So it’s basically equivalent to this: $ echo -n | http httpbin.org/anything |
This error is rather cryptic. I'm writing a shell script to interact with a rest API, and I'm doing this:
Which produces (when preceded by 'echo' a command that works perfectly well. However, this version gives the error in the subject.
Am I being stupid, or is this something else?
FYI: The result of the above is as followed (sanitized slightly)
The text was updated successfully, but these errors were encountered: