cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Downloading a file instead of the web page

From: Peter Bowyer <reywob_at_f2s.com>
Date: Tue, 26 Mar 2002 11:07:46 +0000

At 12:28 AM 3/26/02 +0100, Daniel Stenberg wrote:
>I don't fully comprehend this. "the file is downloaded from the browser" ?
>What does that mean?

Rather than displaying he file in the browser it sends the headers causing
your browser to download the file. Try posting data into the second form
on the page and see what happens.

>If you get a HTML page back instead of the actual file you thought you'd get,
>it might very well be because you did something wrong in your post.

Yes, although the form tells you if some of the entry is wrong.

>When I try that form manually, I get a "application/text" thing back. You
>should get that too when you post with curl.

Can't see it anywhere in the curl verbose output - should I be able to?

>I don't know if this is relevant or not here, but line separators should be
>done with CRLF in posts.

Have changed that but no difference :-)
Does curl encode them or do I have to? My browser was sending %0D%0A
instead of \r\n so I need to now which to send myself.

> > Any advice gratefully received.
>
>Check the headers that are returned. They may reveal interesting things.

They do. with curl on the verbose setting it shows these headers:
* Connected to php-accelerator.co.uk (212.67.208.211)
> POST /activate.php HTTP/1.1
User-Agent: phpa key bot by Peter
Host: www.php-accelerator.co.uk
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Content-Length: 365
Expect: 100-continue
Content-Type: multipart/form-data; boundary=curlR23kNCTQJOv8FaLoBmnU9yDA5+f

Now, when posting from my browser via a proxy, I get the following:
POST /activate.php HTTP/1.0
User-Agent: Opera/6.01 (Windows 98; U) [en]
Host: www.php-accelerator.co.uk
Accept: text/html, image/png, image/jpeg, image/gif, image/x-xbitmap, */*
Accept-Language: en,en-uk,fr
Accept-Charset: windows-1252;q=1.0, utf-8;q=1.0, utf-16;q=1.0,
iso-8859-1;q=0.6, *;q=0.1
Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0
Referer: http://www.php-accelerator.co.uk/activate.php
Content-type: application/x-www-form-urlencoded
Content-length: 51
Connection: keep-alive
Posting 51 bytes...
domain2=test.com%0D%0Atest.co.uk
formname=register2

Notice the different Content-type line? According to the PHP manual the
second Content-type (the one sent from my browser) is the one which curl
should be sending. Is this correct? It's the only difference I can see
which could be causing the problem.

FYI I'm running PHP 4.1.2 with curl 7.9.4(the upgrade should be coming
soon, but I'm at the mercy of the hosting provider)

>Another good idea is to run a network analyzing program that can display what
>your favourite browser sends to the server, as then it is easier for you to
>make sure you send the same things.

Hopefully Proxomitron has done as good a job as a proper network program,
as I've never used one of those :-)

Regards,
Peter.

--oOo--
Narrow Gauge on the web - photos, directory and forums!
http://www.narrow-gauge.co.uk
--oOo--
Glenbranter - Scottish narrow gauge in 009
http://glenbranter.narrow-gauge.co.uk
--oOo--
Received on 2002-03-26