Permalink
Browse files

Merged local master branch and github master branch

  • Loading branch information...
1 parent ae1743f commit 586066c8c7d785b784056d639041dae7967a2b87 @jk jk committed Jul 14, 2011
Showing with 15 additions and 7 deletions.
  1. +11 −3 RestServer.php
  2. +4 −4 sample.htaccess
View
@@ -348,13 +348,21 @@ 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);
-
+
+ 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);
+ }
+
// Check for trailing dot-format syntax like /controller/action.format -> action.json
if(preg_match('/\.(\w+)$/i', $_SERVER['REQUEST_URI'], &$matches)) {
$override = $matches[1];
}
- // Give GET parameters precedence before all other options to alter the format
- $override = isset($_GET['format']) ? $_GET['format'] : '';
+
+ // Give GET parameters precedence before all other options to alter the format
+ $override = isset($_GET['format']) ? $_GET['format'] : $override;
if (isset(RestFormat::$formats[$override])) {
$format = RestFormat::$formats[$override];
} elseif (in_array(RestFormat::AMF, $accept)) {
View
@@ -1,8 +1,8 @@
+# Apache needs to let you overrite this (AllowOverride Indexes or AllowOverride All)
DirectoryIndex index.php
<IfModule mod_rewrite.c>
+ # Turn Rewrite Engine on
RewriteEngine On
- RewriteRule ^$ index.php [QSA,L]
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule ^(.*)$ index.php [QSA,L]
+ # Send all requests to index.php (index.php will parse the request url and routes accordingly)
+ RewriteRule ^.*$ index.php [QSA,L]
</IfModule>

0 comments on commit 586066c

Please sign in to comment.