cli icon indicating copy to clipboard operation
cli copied to clipboard

CF Curl option to exit non-0

Open jeffpak opened this issue 10 years ago • 4 comments

Currently CF curl will always return 0, even if the status code is 4xx or 5xx. We'd like a flag that allows cf curl to return non-zero in these cases.

jeffpak avatar Feb 23 '16 18:02 jeffpak

We have created an issue in Pivotal Tracker to manage this. You can view the current status of your issue at: https://www.pivotaltracker.com/story/show/114328445.

cf-gitbot avatar Feb 23 '16 18:02 cf-gitbot

Hi @jeffpak,

Can you explain more about your use case and why the current spec is insufficient?

Currently we have -i to include the response status code (if there is one) at the top:

200:

D:\Users\koperd\Downloads\bin>cf curl -i /v2/info
HTTP/1.1 200 OK
...

404:

D:\Users\koperd\Downloads\bin>cf curl -i  /v2/info4
HTTP/1.1 404 Not Found
...

This follows the spec of curl itself, which (AFAIK) doesn't offer a flag to redirect it to the command's exit code either.

The command exit code is currently reserved for failures of the command to send the request out. E.g. with missing proxy settings:

D:\projects\cf\cli>cf curl -i  /v2/info4
FAILED
Error creating request:
Error performing request: Get https://api.a1.cf-app.com/v2/info4: dial tcp 52.22.148.164:443: i/o timeout
TIP: If you are behind a firewall and require an HTTP proxy, verify the https_proxy environment variable is correctly set. Else, check your network connection.

D:\projects\cf\cli>echo %ERRORLEVEL%
1

Finally, and I have not confirmed this, but according to a comment on http://superuser.com/questions/590099/can-i-make-curl-fail-with-an-exitcode-different-than-0-if-the-http-status-code-i, codes will wrap at 8 bits, so error 404 becomes exit value 148, 500 becomes 244. Confusing indeed!.

Regards, Dies Koper CF CLI PM

dkoper avatar Feb 23 '16 21:02 dkoper

Closing. Feel free to re-open when you have more information for us.

dkoper avatar Mar 05 '16 00:03 dkoper

Related: #953

Gerg avatar Jul 03 '19 18:07 Gerg