note 83017 added to function.curl-setopt
| From: | hotrodder at rocketmail dot com | Date: | Wed, 07 May 2008 01:26:25 +0000 |
| Subject: | note 83017 added to function.curl-setopt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139119@lists.php.net to get a copy of this message | ||
I just spent the last 45 minutes banging my head against my keyboard because when using libcurl for
a lighttpd server I would get a 400 Bad Request Error.
It turns out, that despite what has been mentioned in other comments, when using the
CURLOPT_HTTPHEADER option, you must use \r\n as newline separators for each header NOT \n. For some
reason lighttpd will not accept them. Other webservers will however.
Example:
<?php
$str = "Accept-Language: en-us,en;q=0.5\r\n";
$str .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
$str .= "Keep-Alive: 300\r\n";
$str .= "Connection: keep-alive\r\n";
curl_setopt($this->curl_handle, CURLOPT_HTTPHEADER, array($str));
?>
----
Server IP: 64.71.164.2
Probable Submitter: 71.163.30.249
----
Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php
Edit -- https://master.php.net/note/edit/83017
Del: integrated -- https://master.php.net/note/delete/83017/integrated
Del: useless -- https://master.php.net/note/delete/83017/useless
Del: bad code -- https://master.php.net/note/delete/83017/bad+code
Del: spam -- https://master.php.net/note/delete/83017/spam
Del: non-english -- https://master.php.net/note/delete/83017/non-english
Del: in docs -- https://master.php.net/note/delete/83017/in+docs
Del: other reasons-- https://master.php.net/note/delete/83017
Reject -- https://master.php.net/note/reject/83017
Search -- https://master.php.net/manage/user-notes.php