Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.1

Request #11060 Negotiate Content functionality
Submitted: 2007-05-16 16:22 UTC
From: enricopulatzo Assigned: jausions
Status: Closed Package: HTTP (version 1.4.0)
PHP Version: Irrelevant OS: *
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 7 + 6 = ?

 
 [2007-05-16 16:22 UTC] enricopulatzo (Josh Peters)
Description: ------------ I would like to see a content negotiation function in PEAR::HTTP that allows a program to list the acceptable mime types it can send and compare it to the user agent's preferences (ala language negotiation). I've created a content negotiation function for HTTP v 1.4.0 that takes either a single content type or a list of types and compares them to the user agent's HTTP Accept header. The best fit is then sent as the content-type header. Test script: --------------- <?php require_once 'HTTP.php'; $mimeType = HTTP::negotiateContentType( array( 'application/xhtml+xml', 'application/xml' ), 'UTF-8', 'application/xml' ); // add the xslt transformation if we're using application/xml if ('application/xml' == $mimeType) { echo <<<_XML_ <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="xhtml.xsl"?> _XML_; } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> ... </html> Expected result: ---------------- the script is served via application/xhtml+xml if the user agent supports it, otherwise served as application/xml with a prolog and stylesheet at the top Actual result: -------------- n/a as this is a feature request

Comments

 [2008-08-31 20:18 UTC] jausions (Philippe Jausions)
Thank you for taking the time to report a problem with the package. Unfortunately you are not using a current version of the package -- the problem might already be fixed. Please download a new version from http://pear.php.net/packages.php If you are able to reproduce the bug with one of the latest versions, please change the package version on this bug report to the version you tested and change the status back to "Open". Again, thank you for your continued support of PEAR.
 [2008-08-31 23:28 UTC] jausions (Philippe Jausions)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/HTTP