Permalink
Browse files

Some updates to rest.php to handle range in Opera, and handle POST

  • Loading branch information...
1 parent a326f1d commit fa6ae2eeaa26466f30653c4cf2f3ea4ebf2af712 @kriszyp committed Aug 10, 2012
Showing with 9 additions and 5 deletions.
  1. +9 −5 test/data/rest.php
View
@@ -4,19 +4,22 @@
if(isset($_GET["parent"])){
$id_prefix = $_GET["parent"]."-";
}
-if(isset($_SERVER["HTTP_RANGE"])){
- preg_match('/(\d+)-(\d+)/',$_SERVER["HTTP_RANGE"], $matches);
+if($_SERVER['REQUEST_METHOD'] == "POST"){
+echo "{id:'1.5', name:'new', comment: 'new comment'}";
+}else{
+if(isset($_SERVER["HTTP_X_RANGE"])){
+ preg_match('/(\d+)-(\d+)/',$_SERVER["HTTP_X_RANGE"], $matches);
$start = $matches[1];
$end = $matches[2];
- if($end > 120){
- $end = 120;
+ if($end > 112){
+ $end = 112;
}
}else{
$start = 0;
$end = 40;
}
-header("Content-Range: " . "items ".$start."-".$end."/120");
+header("Content-Range: " . "items ".$start."-".$end."/112");
echo '[';
for ($i = $start; $i <= $end; $i++) {
if($i != $start){
@@ -25,4 +28,5 @@
echo '{"id":"'.$id_prefix.$i.'","name":"Item '.$i.'","comment":"hello"}';
}
echo ']';
+}
?>

0 comments on commit fa6ae2e

Please sign in to comment.