cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: What's the cURL syntax to download a binary file from a download script URL

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Fri, 28 May 2004 09:05:21 +0200 (CEST)

On Thu, 27 May 2004, Larry Johnson wrote:

> I would like to automate a download of a binary file using cURL.
>
> The problem that I run into is the URL downloads the file fine using IE but
> when I use cURL nothing gets downloaded. I've been banging my head on this
> for a couple of days now without success.

...

> The IE headers look like this
n>
> GET
> /scripts/cust/download.php?path=/place/projects/_3356/stored/&name=3940170.b
> in&projectID=3356&fShow= HTTP/1.1

...

> Cookie: PHPSESSID=29792964b8b5d26399e5062d2159b8e8

Obviously your browser had already received a cookie for this so it could send
it like this. That means you did not start "recording" what IE does from the
start.

Remove all cookies (from this site) again, start recording and start all over.

> HTTP/1.1 200 OK
>
> Set-Cookie: PHPSESSID=29792964b8b5d26399e5062d2159b8e8; path=/
> Content-Length: 0
> Content-Type: application/octet-stream

... is this really the working download response headers? It says the content
is zero bytes!

> And the headers from my attempts with cURL are

...

> Set-Cookie: PHPSESSID=f783ce8bf60603ce516f30ba1b8707d0; path=/
> Content-Disposition: attachment; filename=
> Content-Transfer-Encoding: binary
> Content-Type: application/octet-stream

Hey look, in this response you get a cookie set. This is probably that request
you left out from the IE-recording. If I would guess, I'd say that you need
this cookie set first and then you can request the file if you pass on this
cookie in the file-retrieving request.

> How can I get cURL to imitate what IE does?

Pay attention to cookies. Check the *full* IE sequence. Cross your fingers!
;-)

-- 
     Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
      Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2004-05-28