cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Store file troubleshoot with CURL [Serious Issue]

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 8 Mar 2011 12:02:31 +0100 (CET)

On Tue, 1 Mar 2011, xNokia wrote:

> There are an issue with curl when it comes to there are no filename in the
> URL and no file name on the header as it on megaupload website, if I tried
> to download a file from this URL
> http://www.megaupload.com?d=JLMHQ16K by using the command below
> curl -OLJg --cookie /home/AG/cookies/rapidshare2 -w
> ",%{url_effective},%{size_download},%{content_type}\n"
> http://www.megaupload.com/?d=JLMHQ16K
> The stored filename will be ?d=JLMHQ16K, while it should be crashreport.exe,

By definition it actually should not as curl quite clearly is documented how
it will act in this case.

> I tried to edit the curl source code to let it to capture the file name from
> the latest followed location instead of the initial URL

I wouldn't accept that anyway as unconditional behavior as it would break how
existing scripts work. I'm willing to consider a new option for this though
that would work similar like -J then I guess, altering which name to
ultimately use for the URL.

> I wonder if there anyway to sort the issue by having the CURL to capture the
> filename from the latest followed location if there are no filename in the
> header.

You can easily make a script that first uses a random name with -o, then you
download -w and %{url_effective} to extract the "last" URL and then you get
the file name part off that and rename $random to $file.

> Part of the edits I made:-

If you want to push for such a change you need to provide a full diff/patch.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2011-03-08