Reputation: 30674
How come this works from the BASH prompt:
/testproj> http http://localhost:5000/ping/ &
[1] 10733
(env)
/testproj> HTTP/1.0 200 OK
Content-Length: 2
Content-Type: application/json
Date: Sat, 17 Nov 2018 19:27:01 GMT
Server: Werkzeug/0.14.1 Python/3.6.4
{}
... but fails when executed from in a .sh
:
/testproj> cat x.sh
http http://localhost:5000/ping/ &
(env)
/testproj> ./x.sh
(env)
/testproj> HTTP/1.0 405 METHOD NOT ALLOWED
Allow: GET, HEAD, OPTIONS
Content-Length: 178
Content-Type: text/html
Date: Sat, 17 Nov 2018 19:29:00 GMT
Server: Werkzeug/0.14.1 Python/3.6.4
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The method is not allowed for the requested URL.</p>
?
EDIT: http
is HTTPie
EDIT: type http
gives http is hashed (/testproj/env/bin/http)
EDIT: One can reproduce the error with just http http://www.google.com </dev/null &
(Thanks @e36freak)
EDIT: from e36freak on IRC:
it appears to be an issue with
stdin
i get the same error with justhttp http://www.google.com </dev/null
http
wantsstdin
to be attached to atty
it looks like
for whatever reason
couldn't find it in the man page but i'm sure it's out there
Upvotes: -1
Views: 320
Reputation: 16232
You most like like need to include the --ignore-stdin
option to prevent httpie from trying to read it. See: https://httpie.org/doc#scripting
Upvotes: 1