cURL / Mailing Lists / curl-library / Single Mail

curl-library

cURL Downloading attachment from a forum php script

From: Damian Win <nerexis_at_gmail.com>
Date: Tue, 21 Jun 2011 00:30:02 +0200

Hi,

Im trying to download a file which is an attachment of an Invision Power
Board forum but I have some problems with that.
The problem is that download doesnt start or I don't know how to make it
work because it's not just url to file but to php script which normally
triggers download in browser.

Code Im using (C) :

    curl_easy_reset(curl);
    curl_easy_setopt(curl, CURLOPT_URL, "
http://www.someIPBforum.com/index.php?act=Attach&type=post&id=1428");
    curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1;
WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1");
    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30);
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_easy_setopt(curl, CURLOPT_COOKIEJAR, COOKIE_PATH);
    curl_easy_setopt(curl, CURLOPT_COOKIEFILE, COOKIE_PATH);

    struct MemoryStruct PageData;
    PageData.memory = (char*)malloc(1);
    PageData.size = 0;
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&PageData);

    CURLcode Code = curl_easy_perform(curl);

And response from server is:

* About to connect() to www.someIPBforum.com port 80 (#0)
* Trying <here was ip>... * connected
* Connected to....
> GET /index.php?act=Attach&type=post&id=1428 HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101
Firefox
/4.0.1
Host: www.xxx....
Accept: */*
Referer:
Cookie: ....

< HTTP/1.1 200 OK
< Server: nginx
< Date: Mon, 20 Jun 2011 21:57:08 GMT
< Content-Type: video/mpeg
< Content-Length: 253722
< Last-Modified: Mon, 28 Jun 2004 21:41:05 GMT
< Connection: close
* Replaced cookie session_id........
< Set-Cookie: .......
< Content-Disposition: inline; filename="FILE.MPG"
< P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
* Replaced cookie ....
< Set-Cookie: X-Backend=web5; path=/
< X-Backend: web5
< X-Protocol: http
< X-Country: XX
< Accept-Ranges: bytes
<
* Closing connection #0

So, why download doesnt start. The buffer is empty but respone looks ok.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-06-21