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

curl-and-php

RE: POST requests require a Content-length header error

From: Gary Wakerley <gwak_at_o2.co.uk>
Date: Tue, 3 Feb 2004 08:21:59 -0000

Hi

Operating system XP Pro
Curl Version 7.11.0
Error returned from google

Length Required
POST requests require a Content-length header.

Code used
$var = 'php' ;
$trimmed = trim($var); //trim whitespace from the stored variable
$ch = curl_init();
$user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET
CLR 1.1.4322)";
 curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
 curl_setopt($ch, CURLOPT_URL,"http://www.google.com/search?q="
  . $trimmed . "\" target=\"_blank\" title=\"Look up
  " . $trimmed . " on Google\">Click here");
 curl_setopt($ch, CURLOPT_FAILONERROR, 1);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
 curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
 curl_setopt($ch, CURLOPT_POST, 1); // set POST method
 curl_setopt($ch, CURLOPT_POSTFIELDS,0);
 curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);

 $result = curl_exec ($ch);
 curl_close ($ch);
 echo $result;

Regards

Gary Wakerley
gwak_at_o2.co.uk

-----Original Message-----
From: curl-and-php-admin_at_lists.sourceforge.net
[mailto:curl-and-php-admin_at_lists.sourceforge.net] On Behalf Of Daniel
Stenberg
Sent: 02 February 2004 11:44
To: curl and php list
Subject: Re: POST requests require a Content-length header error

On Thu, 29 Jan 2004, Gary Wakerley wrote:

> Please could someone give some help. I get the POST requests require a
> Content-length header error when I try to access google using php and
curl.
> Has any one had this problem and did you find an answer?

Please try to be a lot more specific when reporting errors.

* curl version?
* operating system?
* what *exactly* does the site report? (preferably including all
headers)
* what headers does curl's request include?
* how can we repeat the problem?

-- 
    Daniel Stenberg -- http://curl.haxx.se/ -- http://daniel.haxx.se/
   [[ Do not send mails to this email address. They won't reach me. ]]
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
Received on 2004-02-03