Buy commercial curl support from WolfSSL. We help you work
out your issues, debug your libcurl applications, use the API, port to new
platforms, add new features and more. With a team lead by the curl founder
himself.
curl with bash and proper error handling
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Siegfried Kiermayer via curl-users <curl-users_at_cool.haxx.se>
Date: Fri, 6 Nov 2020 10:13:35 +0100
Hi!
i'm struggling with a simple issue for a while now and still have not
found a good solution:
When using curl in a bash script, I have not found a simple/reliable
way to get either the response I'm looking for or the error response +
a proper http status code.
I have found so far:
- -f which doesn't return the response content and the man page also states:
"This method is not fail-safe and there are occasions where
non-successful response codes will slip through, especially when
authentication is involved (response codes 401 and 407)."
- modifying the output that the http status code is before the
content, cutting the http status code from the content:
I have seen this tip a few times, one example is here:
https://www.joyfulbikeshedding.com/blog/2020-05-11-best-practices-when-using-curl-in-shell-scripts.html
I just want to get the content of a http request and the status code.
The content to either use it directly or to make it visible in a way
that I'm able to see the issue when my curl command fails inside my
script.
I do have a few suggestions, but I also assume there are reasons why
it's not supported, perhaps someone can shed light on it?
1. Is there a specific reason why -f ignores 401?
2. Would it be possible to make -f return the content on stdout and/or
as file? Perhaps even as an additional file?
3. Could curl return the first number as a sub status code? Like 1,2,3,4 or 5?
Note: Its unfortunate that the error code size is limited, at
least the first number could give someone an idea;
4. Perhaps curl could allow a filter list instead. Like a way to tell
curl what is OK and what not
Thanks,
Sigi
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-11-06
Date: Fri, 6 Nov 2020 10:13:35 +0100
Hi!
i'm struggling with a simple issue for a while now and still have not
found a good solution:
When using curl in a bash script, I have not found a simple/reliable
way to get either the response I'm looking for or the error response +
a proper http status code.
I have found so far:
- -f which doesn't return the response content and the man page also states:
"This method is not fail-safe and there are occasions where
non-successful response codes will slip through, especially when
authentication is involved (response codes 401 and 407)."
- modifying the output that the http status code is before the
content, cutting the http status code from the content:
I have seen this tip a few times, one example is here:
https://www.joyfulbikeshedding.com/blog/2020-05-11-best-practices-when-using-curl-in-shell-scripts.html
I just want to get the content of a http request and the status code.
The content to either use it directly or to make it visible in a way
that I'm able to see the issue when my curl command fails inside my
script.
I do have a few suggestions, but I also assume there are reasons why
it's not supported, perhaps someone can shed light on it?
1. Is there a specific reason why -f ignores 401?
2. Would it be possible to make -f return the content on stdout and/or
as file? Perhaps even as an additional file?
3. Could curl return the first number as a sub status code? Like 1,2,3,4 or 5?
Note: Its unfortunate that the error code size is limited, at
least the first number could give someone an idea;
4. Perhaps curl could allow a filter list instead. Like a way to tell
curl what is OK and what not
Thanks,
Sigi
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-11-06