Why is PHP's cURL is prefixing HTTP headers with "HTTP_"?

I am sending the http header X-SSID, but server receives it as HTTP_X_SSID. I'm using cURL but it's not required; I just need to send this header by post method and get content.

Here's the code I'm using to make the request:

$ch = curl_init();

// ... other setup code; see link above for full context)

curl_setopt($ch, CURLOPT_HTTPHEADER, arrat(
  "X-SSID: {$ssid}",
  "X-API_VERSION: 2"
});

$server_output = curl_exec($ch);
var_dump($ssid, $server_output);
curl_close($ch);

Here's how the server sees the request:

["HTTP_X_SSID"]=>
string(32) "[truncated]"
["HTTP_X_API_VERSION"]=>
string(1) "2"

Upvotes: 0

Views: 202

Answers (1)

wodka
wodka

Reputation: 1380

If you are checking the headers in php please note that they are exposed like this.

ie sending X-test will produce a global var $HTTP_X_TEST

Upvotes: 2

Related Questions