Created
October 21, 2010 14:27
-
-
Save namlet/638577 to your computer and use it in GitHub Desktop.
Fix to ApiServlet Class in Shindig PHP Port. Should honor Accept header before Content-Type.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (isset($_SERVER['HTTP_ACCEPT'])) { | |
// normalize things like "application/json; charset=utf-8" to application/json | |
foreach ($acceptedContentTypes as $contentType) { | |
if (strpos(strtolower($_SERVER['HTTP_ACCEPT']), $contentType) !== false) { | |
$_SERVER['HTTP_ACCEPT'] = $contentType; | |
$this->setContentType($contentType); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not a complete solution. This only sets the Response headers, not the output format. In addition, this block and the similar CONTENT_TYPE block should be contained by a block to determine if either are set before processing to preserve correct behavior when defaults are used.