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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dougdrury
Forum Newbie
Posts: 4
Joined: Mon Aug 28, 2006 2:37 pm

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

Post 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
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

would get_headers() work?
dougdrury
Forum Newbie
Posts: 4
Joined: Mon Aug 28, 2006 2:37 pm

Post 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.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

then... Image
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
dougdrury
Forum Newbie
Posts: 4
Joined: Mon Aug 28, 2006 2:37 pm

Thanks

Post 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
dougdrury
Forum Newbie
Posts: 4
Joined: Mon Aug 28, 2006 2:37 pm

Apache 2, PHP5 and apache_request_headers()

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply