Permalink
Browse files

Enable the possibility to choose the format via HTTP request headers …

…(i.e. with »HTTP Client« from the Mac AppStore)
  • Loading branch information...
1 parent 81eaad5 commit 0d8c517f6399eea476c3d632c3ca4c5270dee322 Jens Kohl committed Apr 22, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 RestServer.php
View
@@ -345,8 +345,14 @@ public function getFormat()
$format = RestFormat::PLAIN;
$accept_mod = preg_replace('/\s+/i', '', $_SERVER['HTTP_ACCEPT']); // ensures that exploding the HTTP_ACCEPT string does not get confused by whitespaces
$accept = explode(',', $accept_mod);
-
- $override = isset($_GET['format']) ? $_GET['format'] : '';
+
+ if (isset($_REQUEST['format']) || isset($_SERVER['HTTP_FORMAT'])) {
+ // give GET/POST precedence over HTTP request headers
+ $override = isset($_SERVER['HTTP_FORMAT']) ? $_SERVER['HTTP_FORMAT'] : '';
+ $override = isset($_REQUEST['format']) ? $_REQUEST['format'] : $override;
+ $override = trim($override);
+ }
+
if (isset(RestFormat::$formats[$override])) {
$format = RestFormat::$formats[$override];
} elseif (in_array(RestFormat::AMF, $accept)) {

0 comments on commit 0d8c517

Please sign in to comment.