Buy commercial curl support. 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 Daniel himself.
[IDEA] --write-out print body on http error code
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Bastian Jesuiter via curl-users <curl-users_at_lists.haxx.se>
Date: Wed, 24 Jul 2024 09:28:42 +0200
Hi,
Would it be possible to add a --write-out variable, to allow printing of
the body, In case the http code is an error (not 20* status code) ?
For example, I provide a curl command for other users to download a file,
which may be available, or in some cases not available due to a scan which
may block the request temporarily.
Thus, since it is supposed to be a file, the command uses -o to write the
output to a file. When the status code is an error it either writes the
request body (the error) to the specified file, unless --fail is used.
But if --fail is used, no body is printed into neither the file nor stdout.
In a lot of cases, servers (like Artifactory) usually respond with some
kind of error message in the return, which may be helpful to know to the
person using the command.
Using write-out to optionally print the body if an error occured seems
useful in this case.
Sure it could print the status code along a custom message, but the
specific error from the body may be more helpful than a static error
message I can write.
I'm not sure how much work it would be, thus this is just a small idea for
potential improvement.
Thanks,
Bastian
Date: Wed, 24 Jul 2024 09:28:42 +0200
Hi,
Would it be possible to add a --write-out variable, to allow printing of
the body, In case the http code is an error (not 20* status code) ?
For example, I provide a curl command for other users to download a file,
which may be available, or in some cases not available due to a scan which
may block the request temporarily.
Thus, since it is supposed to be a file, the command uses -o to write the
output to a file. When the status code is an error it either writes the
request body (the error) to the specified file, unless --fail is used.
But if --fail is used, no body is printed into neither the file nor stdout.
In a lot of cases, servers (like Artifactory) usually respond with some
kind of error message in the return, which may be helpful to know to the
person using the command.
Using write-out to optionally print the body if an error occured seems
useful in this case.
Sure it could print the status code along a custom message, but the
specific error from the body may be more helpful than a static error
message I can write.
I'm not sure how much work it would be, thus this is just a small idea for
potential improvement.
Thanks,
Bastian
-- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users Etiquette: https://curl.se/mail/etiquette.htmlReceived on 2024-07-24