Naumaan
Naumaan

Reputation: 33

PHP process HTTP headers

How do I obtain the HTTP headers in response to a POST request I made with PHP?

Upvotes: 3

Views: 1354

Answers (3)

Steve Clay
Steve Clay

Reputation: 8781

Create an HTTP stream context and pass it into file_get_contents(). Afterwards, you can:

$metaData = stream_get_meta_data($context);
$headers = $metaData['wrapper_data'];

Upvotes: 2

grantwparks
grantwparks

Reputation: 1153

How did you issue the POST? I use a socket and then read back the response where I get headers and body.

Upvotes: 0

back2dos
back2dos

Reputation: 15623

you will find them in the superglobal $_SERVER ... anything that starts with HTTP_ should be a header ... it depends on the server, how well this will work ...

greetz

back2dos

Upvotes: 1

Related Questions