You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Warning: Failed to open ./test/headers.txt
curl: (23) Failed writing received data to disk/application
I expected the following
Headers to be saved in the directory specified, even if it doesn't already exist, due to the --create-dirs option.
Obviously for a simple example like this, the directory can be manually created first. However, when used in a large config file with thousands of URLs, it is not possible to automatically save headers and responses into a custom directory per-URL (without first creating every single directory required, which defeats the value of --create-dirs).
(The use of --next is needed in order to reset --output-dir per URL. Different directories are needed per URL in this use case as different download IDs can have the same filename in the Content-Disposition header and both the download ID and filename need to be preserved in the resulting structure).
Without the dump-header lines, curl correctly uses the --create-dirs option and creates the directories when it comes to saving the actual response bodies. But because the headers come before the body, the directory does not exist at the time the headers are written, and curl errors out.
Without the dump-header lines, the rest of the config works really well for this use case. Thanks!
Suggested change:
In the dump-header code, if the provided value contains leading directories and they don't exist, before returning an error, first check if the --create-dirs option has been provided, and then first try to create the required directory tree (in the same way that --create-dirs works with --output). Only if that fails, then return an error, otherwise continue with the rest of the command.
curl/libcurl version
curl 8.10.0
operating system
Ubuntu 22.04
The text was updated successfully, but these errors were encountered:
I did this
Result:
I expected the following
Headers to be saved in the directory specified, even if it doesn't already exist, due to the
--create-dirs
option.Obviously for a simple example like this, the directory can be manually created first. However, when used in a large config file with thousands of URLs, it is not possible to automatically save headers and responses into a custom directory per-URL (without first creating every single directory required, which defeats the value of
--create-dirs
).E.g., in a config file such as this:
(The use of
--next
is needed in order to reset--output-dir
per URL. Different directories are needed per URL in this use case as different download IDs can have the same filename in theContent-Disposition
header and both the download ID and filename need to be preserved in the resulting structure).Without the
dump-header
lines, curl correctly uses the--create-dirs
option and creates the directories when it comes to saving the actual response bodies. But because the headers come before the body, the directory does not exist at the time the headers are written, and curl errors out.Without the
dump-header
lines, the rest of the config works really well for this use case. Thanks!Suggested change:
In the
dump-header
code, if the provided value contains leading directories and they don't exist, before returning an error, first check if the--create-dirs
option has been provided, and then first try to create the required directory tree (in the same way that--create-dirs
works with--output
). Only if that fails, then return an error, otherwise continue with the rest of the command.curl/libcurl version
curl 8.10.0
operating system
Ubuntu 22.04
The text was updated successfully, but these errors were encountered: