Is there anyway to get the client request headers?
I tried apache_request_headers() but it doesnt work.
Is there anyway to get the client request headers?
I tried apache_request_headers() but it doesnt work.
programmer in java, c++, vb6, vb.net, php, asp & mysql amongst others.
Is there no way to do this using bluehost servers?
this is essential to my current project. I must find a way to read the request headers sent by the client.
Perhaps another serverside language can do this? I am willing to learn if there is a way.
programmer in java, c++, vb6, vb.net, php, asp & mysql amongst others.
That function is only available if PHP is installed as an Apache module, which it isn't on bluehost.
What exactly do you need from the headers for your script to work? Perhaps there is a work-around for it as a lot of the headers are available through the $_SERVER variable.
Edit: Actually, I did a test, $_SERVER seems to have the same data that apache_request_headers() has.
So you could use a function like:
On my test server apache_request_headers returned:PHP Code:function getHeaders()
{
$headers = array();
foreach ($_SERVER as $k => $v)
{
if (substr($k, 0, 5) == "HTTP_")
{
$k = str_replace('_', ' ', substr($k, 5));
$k = str_replace(' ', '-', ucwords(strtolower($k)));
$headers[$k] = $v;
}
}
return $headers;
}
and that function returned:Code:Array ( [Host] => localhost [User-Agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4 [Accept] => text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 [Accept-Language] => en-us,en;q=0.5 [Accept-Encoding] => gzip,deflate [Accept-Charset] => ISO-8859-1,utf-8;q=0.7,*;q=0.7 [Keep-Alive] => 300 [Connection] => keep-alive [Cache-Control] => max-age=0 )
Code:Array ( [Host] => localhost [User-Agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4 [Accept] => text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 [Accept-Language] => en-us,en;q=0.5 [Accept-Encoding] => gzip,deflate [Accept-Charset] => ISO-8859-1,utf-8;q=0.7,*;q=0.7 [Keep-Alive] => 300 [Connection] => keep-alive [Cache-Control] => max-age=0 )
Last edited by lazynitwit; 07-16-2006 at 02:09 PM.
BlueHost Knowledge Base, it is quite helpful, you should read through it.
I'll try out the $_SERVER global variable, thanks.
The problem I found is that I need to get _all_ the headers, not just traditional headers sent by the browser. The application used will send custom headers that arent used by browsers.
this for example
programmer in java, c++, vb6, vb.net, php, asp & mysql amongst others.
It should still work, I sent my test server the following:Originally Posted by solarnexus
It replied:Code:GET /headertest.php HTTP/1.1 Host: localhost Test-Header: testing Connection: CloseNote that in the $_SERVER array it would actually be:Code:apache_request_headers(): Array ( [Host] => localhost [Test-Header] => testing [Connection] => Close ) $_SERVER: Array ( [Host] => localhost [Test-Header] => testing [Connection] => Close )
Code:Array ( [HTTP_HOST] => localhost [HTTP_TEST_HEADER] => testing [HTTP_CONNECTION] => Close )
BlueHost Knowledge Base, it is quite helpful, you should read through it.