Page 1 of 1

Extracting content type from client HTTP request

Posted: Thu Jul 15, 2004 7:01 pm
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

Posted: Thu Jul 15, 2004 7:13 pm
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>'; ?>

What is print_r()?

Posted: Thu Jul 15, 2004 7:28 pm
by myleow
This is my output

Warning: Wrong parameter count for print_r() in /home/myleow/public_html/syncml/index.php on line 3

Posted: Thu Jul 15, 2004 7:35 pm
by feyd
uh ok... hmmm :? [php_man]print_r[/php_man]

Posted: Thu Jul 15, 2004 7:37 pm
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]

Posted: Thu Jul 15, 2004 8:04 pm
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.