aboutsummaryrefslogtreecommitdiffstats
path: root/test/data/ajax
diff options
context:
space:
mode:
Diffstat (limited to 'test/data/ajax')
-rw-r--r--test/data/ajax/echo/index.php43
-rw-r--r--test/data/ajax/headers/cache/index.php30
-rw-r--r--test/data/ajax/headers/request/index.php12
-rw-r--r--test/data/ajax/headers/response/index.php5
4 files changed, 90 insertions, 0 deletions
diff --git a/test/data/ajax/echo/index.php b/test/data/ajax/echo/index.php
new file mode 100644
index 000000000..a03fe4b0d
--- /dev/null
+++ b/test/data/ajax/echo/index.php
@@ -0,0 +1,43 @@
+<?php
+
+ $requestArray = "REQUEST";
+
+ if ( isset( $_REQUEST["requestArray"] ) ) {
+ $requestArray = $_REQUEST["requestArray"];
+ }
+
+ $requestArray =& ${"_$requestArray"};
+
+ $response = array(
+ "status" => "200",
+ "statusText" => "",
+ "contentType" => "text/plain",
+ "content" => "",
+ "callback" => "",
+ "delay" => 0
+ );
+
+ foreach( $response as $field => &$value ) {
+ if ( isset( $requestArray[ $field ] ) ) {
+ $value = $requestArray[ $field ];
+ }
+ }
+
+ if ( is_array( $response["content"] ) ) {
+ $response["content"] = http_build_query( $response["content"] );
+ }
+
+ if ( !$response["callback"] && preg_match( '/index.php\/([^\/\?&]+)/', $_SERVER["REQUEST_URI"], $match ) ) {
+ $response["callback"] = $match[ 1 ];
+ }
+
+ header("HTTP/1.1 $response[status] $response[statusText]");
+ header("Content-Type: $response[contentType]");
+
+ if ( $response["delay"] ) {
+ sleep( $response["delay"] );
+ }
+
+ echo $response["callback"]
+ ? "$response[callback](" . json_encode("$response[content]") . ");"
+ : "$response[content]";
diff --git a/test/data/ajax/headers/cache/index.php b/test/data/ajax/headers/cache/index.php
new file mode 100644
index 000000000..c52b665bd
--- /dev/null
+++ b/test/data/ajax/headers/cache/index.php
@@ -0,0 +1,30 @@
+<?php
+$headers = array(
+
+ "If-Modified-Since" => array(
+ "request" => "HTTP_IF_MODIFIED_SINCE",
+ "response" => "Last-Modified",
+ ),
+ "If-None-Match" => array(
+ "request" => "HTTP_IF_NONE_MATCH",
+ "response" => "Etag",
+ ),
+
+);
+
+$header = $_REQUEST["header"];
+$value = $_REQUEST["value"];
+
+if ( $header === "If-None-Match" ) {
+ $value = md5( $value );
+}
+
+$headers = $headers[ $header ];
+
+$requestHeader = isset( $_SERVER[ $headers["request"] ] ) ? stripslashes($_SERVER[ $headers["request"] ]) : false;
+if ( $requestHeader === $value ) {
+ header("HTTP/1.0 304 Not Modified");
+} else {
+ header("$headers[response]: $value");
+ echo $requestHeader ? "OK: $value": "FAIL";
+}
diff --git a/test/data/ajax/headers/request/index.php b/test/data/ajax/headers/request/index.php
new file mode 100644
index 000000000..c064ad709
--- /dev/null
+++ b/test/data/ajax/headers/request/index.php
@@ -0,0 +1,12 @@
+<?php
+
+$headers = array();
+
+foreach( $_SERVER as $key => $value ) {
+ $key = str_replace( "_" , "-" , substr($key,0,5) == "HTTP_" ? substr($key,5) : $key );
+ $headers[ $key ] = $value;
+}
+
+foreach( explode( "," , $_GET["headers"] ) as $key ) {
+ echo "$key: " . @$headers[ strtoupper( $key ) ] . "\n";
+}
diff --git a/test/data/ajax/headers/response/index.php b/test/data/ajax/headers/response/index.php
new file mode 100644
index 000000000..6c8d0864e
--- /dev/null
+++ b/test/data/ajax/headers/response/index.php
@@ -0,0 +1,5 @@
+<?php
+
+foreach( $_REQUEST as $header => $value ) {
+ @header("$header: $value");
+}