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.
-J should truly mean "allow the server to select the file name"
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Robin A. Meade via curl-users <curl-users_at_lists.haxx.se>
Date: Tue, 12 Oct 2021 15:48:49 -1000
I read at
https://daniel.haxx.se/blog/2020/09/10/store-the-curl-output-over-there/
that -J means "allow the server to select the file name."
Currently, when determining what filename the server selected, curl's -J
option considers only the 'content-disposition' header.
When -L, --location option is used, and the 'content-disposition' header
is absent, I propose that the -J option also consider the file part of
any redirect location.
With this change, the documentation of the -J option would need a new
paragraph:
-J, --remote-header-name
(HTTP) This option tells the -O, --remote-name option to use the
server-specified Content-Disposition filename instead of
extracting a filename from the URL.
+ When used in combination with -L, --location option and no
+ Content-Disposition is sent, the file part of any location
+ the server redirects to will be treated as the server specified
+ file name.
If the server specifies a file name and a file with that name
already exists in the current working directory it will not be
overwritten and an error will occur. If the server doesn't
specify a file name then this option has no effect.
This came up because I wrote a script to download the discord
application. My script included the following curl invocation:
curl -LOJ \
'https://discordapp.com/api/download?platform=linux&format=tar.gz'
This results in this difficult file name:
download?platform=linux&format=tar.gz
My colleague changed my script to use wget:
wget --content-disposition \
'https://discordapp.com/api/download?platform=linux&format=tar.gz'
which resulted in this nicer file name:
discord-0.0.16.tar.gz
which is what I get if I download the URL in Firefox or Chrome.
I prefer curl, so I changed it back to this two step curl procedure:
url='https://discordapp.com/api/download?platform=linux&format=tar.gz'
url_effective=$(
curl -sS -L -I "$url" -o /dev/null \
-w '%{url_effective}'
)
curl -O "$url_effective"
I'd prefer the -J option to truly mean "allow the server to select the
file name."
Thank you for considering this change to the -J, --remote-header-name
option.
Robin
Date: Tue, 12 Oct 2021 15:48:49 -1000
I read at
https://daniel.haxx.se/blog/2020/09/10/store-the-curl-output-over-there/
that -J means "allow the server to select the file name."
Currently, when determining what filename the server selected, curl's -J
option considers only the 'content-disposition' header.
When -L, --location option is used, and the 'content-disposition' header
is absent, I propose that the -J option also consider the file part of
any redirect location.
With this change, the documentation of the -J option would need a new
paragraph:
-J, --remote-header-name
(HTTP) This option tells the -O, --remote-name option to use the
server-specified Content-Disposition filename instead of
extracting a filename from the URL.
+ When used in combination with -L, --location option and no
+ Content-Disposition is sent, the file part of any location
+ the server redirects to will be treated as the server specified
+ file name.
If the server specifies a file name and a file with that name
already exists in the current working directory it will not be
overwritten and an error will occur. If the server doesn't
specify a file name then this option has no effect.
This came up because I wrote a script to download the discord
application. My script included the following curl invocation:
curl -LOJ \
'https://discordapp.com/api/download?platform=linux&format=tar.gz'
This results in this difficult file name:
download?platform=linux&format=tar.gz
My colleague changed my script to use wget:
wget --content-disposition \
'https://discordapp.com/api/download?platform=linux&format=tar.gz'
which resulted in this nicer file name:
discord-0.0.16.tar.gz
which is what I get if I download the URL in Firefox or Chrome.
I prefer curl, so I changed it back to this two step curl procedure:
url='https://discordapp.com/api/download?platform=linux&format=tar.gz'
url_effective=$(
curl -sS -L -I "$url" -o /dev/null \
-w '%{url_effective}'
)
curl -O "$url_effective"
I'd prefer the -J option to truly mean "allow the server to select the
file name."
Thank you for considering this change to the -J, --remote-header-name
option.
Robin
-- Robin A. Meade robin.a.meade_at_gmail.com -- Unsubscribe: https://lists.haxx.se/listinfo/curl-users Etiquette: https://curl.haxx.se/mail/etiquette.htmlReceived on 2021-10-13