[cvs-annodex] commit (/annodex):
phpannodex/trunk/phpsrc/CGI/nph-mod_annodex.php
ctford
nobody at lists.annodex.net
Thu Jan 5 16:37:48 EST 2006
Update of /annodex (new revision 1753)
Modified files:
phpannodex/trunk/phpsrc/CGI/nph-mod_annodex.php
Log Message:
Properly parses Accept field of HTTP header and responds with CMML or Annodex appropriately.
Modified: phpannodex/trunk/phpsrc/CGI/nph-mod_annodex.php
===================================================================
--- phpannodex/trunk/phpsrc/CGI/nph-mod_annodex.php 2006-01-05 04:59:17 UTC (rev 1752)
+++ phpannodex/trunk/phpsrc/CGI/nph-mod_annodex.php 2006-01-05 05:37:47 UTC (rev 1753)
@@ -14,7 +14,7 @@
* application/x-annodex then we want to output cmml. Otherwise we want
* to output annodex.
*/
- if( cmml_prioritised( $http_accept ) ) {
+ if( cmml_prioritised( $_SERVER['HTTP_ACCEPT'] ) ) {
output_cmml( $filename_root );
} else {
output_annodex( $filename_root );
@@ -46,18 +46,30 @@
/* Break up the accept field of the request so we can parse it. */
$accept_array = explode(",",$http_accept);
- foreach( $accept_array as $key => $type ) {
- $accept_array[$key] = explode(";",$type);
- if( $accept_array[$key][1]=="text/x-cmml" ) {
+ foreach( $accept_array as $type ) {
+ $type_tuple = explode(";",$type);
+ if( $type_tuple[0]=="text/x-cmml" ) {
/* Found cmml before annodex. */
- return true;
+ if( count($type_tuple) == 2 ) {
+ $cmml_priority = $type_tuple[1];
+ } else {
+ $cmml_priority = 1;
+ }
} else if ( $accept_array[$key][1]=="application/x-annodex" ) {
/* Found annodex before cmml. */
- return false;
+ if( count($type_tuple) == 2 ) {
+ $anx_priority = $type_tuple[1];
+ } else {
+ $anx_priority = 1;
+ }
}
}
- /* Neither cmml nor annodex found. */
- return false;
+
+ if( $cmml_priority > $anx_priority ) {
+ return true;
+ } else {
+ return false;
+ }
}
/* Output the boring header stuff. Does not specify Content-Type, as
--
ctford
More information about the cvs-annodex
mailing list