Skip to content

Instantly share code, notes, and snippets.

@namlet
Created October 21, 2010 14:27
Show Gist options
  • Save namlet/638577 to your computer and use it in GitHub Desktop.
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.
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;
}
}
}
@namlet
Copy link
Author

namlet commented Oct 21, 2010

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment