This would be very convenient way to fail fast scripts that run with -e
This would be like curl --fail only without swallowing the output.
It looks that now the return code is always 0.
$ http -v PUT invalid://httpbin.org/put API-Key:foo hello=world
http: error: InvalidSchema: No connection adapters were found for 'invalid://httpbin.org/put'
$ echo $#
0
$ http PUT httpbin.org/status/418 API-Key:foo hello=world
HTTP/1.1 418 I'M A TEAPOT
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: close
Content-Length: 135
Date: Wed, 20 Sep 2017 13:02:15 GMT
Server: gunicorn/19.7.1
X-Powered-By: Flask
X-Processed-Time: 0
x-more-info: http://tools.ietf.org/html/rfc2324
-=[ teapot ]=-
_...._
.' _ _ `.
| ."` ^ `". _,
\_;`"---"`|//
| ;/
\_ _/
`"""`
$ echo $#
0
@jakub-bochenski I think you wanted to print $?, which gives you 1 for the first example. For the second one, you can get an error status code on an error response with --check-status: https://httpie.org/doc#scripting
Indeed -- sorry about that.
I tried greping the docs for "status code" and "return code" before but didn't find the --check-status option. Good to know it's there.
Most helpful comment
@jakub-bochenski I think you wanted to print
$?, which gives you1for the first example. For the second one, you can get an error status code on an error response with--check-status: https://httpie.org/doc#scripting