Extracting content type from client HTTP request

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
myleow
Forum Contributor
Posts: 194
Joined: Mon Jun 21, 2004 7:05 pm
Location: California

Extracting content type from client HTTP request

Post by myleow »

Time to bother all of you PHP experts again.

Today my question is about the correct way to extract a CONTENT TYPE from the Client HTTP request Header.

I tried using $_SERVER['CONTENT_TYPE'] and that didn't return anything to me when i tried echo-ing it.

Can anyone help me on this one and tell me the way to extract such information?

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

Post by feyd »

content-type isn't sent in the client request, that I remember. Accept types may be passed however.. check the output of

Code: Select all

<?php echo '<pre>'.print_r($_SERVER,true).'</pre>'; ?>
myleow
Forum Contributor
Posts: 194
Joined: Mon Jun 21, 2004 7:05 pm
Location: California

What is print_r()?

Post by myleow »

This is my output

Warning: Wrong parameter count for print_r() in /home/myleow/public_html/syncml/index.php on line 3
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

uh ok... hmmm :? [php_man]print_r[/php_man]
myleow
Forum Contributor
Posts: 194
Joined: Mon Jun 21, 2004 7:05 pm
Location: California

Post by myleow »

Oh it works without the TRUE arguement.

just $_SERVER is enough.

This is what i got.

Code: Select all

Array ( &#1111;DOCUMENT_ROOT] => /var/www &#1111;HTTP_ACCEPT] => */* &#1111;HTTP_ACCEPT_ENCODING] => gzip, deflate &#1111;HTTP_ACCEPT_LANGUAGE] => en-us &#1111;HTTP_CONNECTION] => Keep-Alive &#1111;HTTP_HOST] => pc6.homelinux.com &#1111;HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322) &#1111;PATH] => /bin:/usr/bin:/sbin:/usr/sbin &#1111;REMOTE_ADDR] => 63.202.21.11 &#1111;REMOTE_PORT] => 61036 &#1111;SCRIPT_FILENAME] => /home/myleow/public_html/syncml/index.php &#1111;SERVER_ADDR] => 192.168.1.101 &#1111;SERVER_ADMIN] => webmaster@icees.com &#1111;SERVER_NAME] => www.icees.com &#1111;SERVER_PORT] => 80 &#1111;SERVER_SIGNATURE] => 
Apache/1.3.26 Server at www.icees.com Port 80
&#1111;SERVER_SOFTWARE] => Apache/1.3.26 (Unix) Debian GNU/Linux PHP/4.1.2 &#1111;UNIQUE_ID] => QPchIX8AAAEAAHjWJt0 &#1111;GATEWAY_INTERFACE] => CGI/1.1 &#1111;SERVER_PROTOCOL] => HTTP/1.1 &#1111;REQUEST_METHOD] => GET &#1111;QUERY_STRING] => &#1111;REQUEST_URI] => /~myleow/syncml/index.php &#1111;SCRIPT_NAME] => /~myleow/syncml/index.php &#1111;PATH_TRANSLATED] => /home/myleow/public_html/syncml/index.php &#1111;PHP_SELF] => /~myleow/syncml/index.php &#1111;argv] => Array ( ) &#1111;argc] => 0 ) 
1
Well i don't see any thing related to content type and majority of the information are of the server, except for HTTP_USER_AGENT.

What i am trying develop is a SyncML server that can communicate with my Sony Ericsson T 616.

I don't know which port the phone is trying to communicate with, i assume that it is trying to communicate with port 80 because SyncML has HTTP binding.

[Edit: Added CODE tags for eyecandy. --JAM]
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

http://www.openmobilealliance.org/tech/ ... t-type.htm
?

Don't think (not entirely sure tho) that you will find this in the global $_SERVER. You should rather lookup the type using the Whitepaper (PDF) or massive googling.
Post Reply