Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 0d8c517f6399eea476c3d632c3ca4c5270dee322 1 parent 81eaad5
Jens Kohl authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 RestServer.php
View
10 RestServer.php
@@ -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)) {
Please sign in to comment.
Something went wrong with that request. Please try again.