Page 1 of 1

List Custom Request Headers w/ PHP5 on Win Svr 2003/IIS6

Posted: Mon Aug 28, 2006 2:49 pm
by dougdrury
Folks,

I am coding a project that will be using custom mime type headers to do alot of the communication between servers via POSTs. It is a poor mans 'web service'. I need to be able to list the incoming custom request headers and read their values to do certain logic. I have googled the heck out of this topic and only can find the apache_request_headers() function...but I am not running on Apache. I did find a function that looked into the $_SERVER variable and looked at the HTTP_* items...but that doesn't help me with the custom headers I am sending.

Am I just missing something simple? I have a POST class that I can POST any custom headers I want...I just can't find code to read those headers from the server upon receiving the request. The $headers array is only for what the response headers will be.

Any help would greatly be appreciated.

Thanks,
Doug

Posted: Mon Aug 28, 2006 3:02 pm
by Luke
would get_headers() work?

Posted: Mon Aug 28, 2006 3:20 pm
by dougdrury
Thanks The Ninja Space Goat,
But, get_headers() will only show me the response headers from a request that I make...not from an incoming POST.

Posted: Mon Aug 28, 2006 3:24 pm
by Luke
then... Image

Posted: Mon Aug 28, 2006 4:14 pm
by feyd
As far as I can recall there is no native functionality to provide you with the full request headers for a given page query. If your particular webserver doesn't have functionality exposed by PHP, you may need to seek other means of getting it. What that is, I can't say. If you want to stay in PHP, you could always load up the HTTP Daemon built entirely in PHP and modify it to give you the full headers. Alternately you could move away from these "custom" non-standard headers.

Thanks

Posted: Mon Aug 28, 2006 4:17 pm
by dougdrury
Thanks feyd. If I find something that works, I will post it here. I fear you are right. I may just have to load up apache and see what that gives me.

Thanks again,
Doug

Apache 2, PHP5 and apache_request_headers()

Posted: Mon Aug 28, 2006 4:34 pm
by dougdrury
I actually had another server running Apache2 and PHP5. I posted to it sending a custom header "X-Transaction-ID: 123456" and had that page use apache_request_headers() as the only item. The function did not show me my custom headers.

Does apache_request_headers() just show certain headers? Is there anyway that I can just get access to the request headers section via some env variable?

Here is the output of my "test_post.php" script that I use to POST to many different pages.

Request:
POST /request_headers.php HTTP/1.1
Host: this-is-not-the-host.com
User-Agent: httpclient (httpclient $Revision: 1.40 $)
Content-Type: multipart/form-data; boundary=--df35ca6ada5fafe6c0786e3811c53b9c
Content-Length: 3779
X-Transaction-ID: 123444

Response headers:
http/1.1 200 ok:
date: Mon, 28 Aug 2006 21:31:43 GMT
server: Apache
x-powered-by: PHP/5.0.4
content-length: 209
connection: close
content-type: text/html; charset=ISO-8859-1

Response body:
Host: this-is-not-the-host.com
User-Agent: httpclient (httpclient $Revision: 1.40 $)
Content-Type: multipart/form-data; boundary=--df35ca6ada5fafe6c0786e3811c53b9c
Content-Length: 3779

I must be missing something. I thought that apache_request_headers() would return *ALL* the headers...no matter what they were.

Hmmmm... I am flummoxed.

Posted: Mon Aug 28, 2006 4:41 pm
by feyd
You're free to check $_ENV, but I don't think they'll be there.

As I said before, if you must use PHP, the only option I can see that'd be effective, outside of not even going this route, is to load the pure PHP HTTP Daemon that was built some time ago as a test bed.

I do really think you should use standard headers however.