Reputation: 5062
What is difference between below headers sent by cURL?
$header="POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .="Content-Type: application/x-www-form-urlencoded\r\n";
$header .="Host: www.paypal.com\r\n";
$header .="Connection: close\r\n\r\n";
And
$header = array ('POST /cgi-bin/webscr HTTP/1.1', 'Content-Type: application/x-www-form-urlencoded', 'Host: www.paypal.com', 'Connection: close');
Used for
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
Can I use both methods for setting up headers for cURL?Thanks
Upvotes: 0
Views: 656
Reputation: 58214
Both solutions are wrong although the second is less wrong.
Both include the POST line which is the request line and not actually a header by definition. Thus, including that in the header option will create a bad request. (but yes, it may still work)
Upvotes: 1