<?php
/**
 * Provides a simple response with information about the request. This is used
 * by the RestClient unit tests to verify the RestClient module is working
 * properly.
 */
if (strpos(serialize(getallheaders()), "json") !== false)
{
    header("Content-Type: application/json");
}
else
{
    header("Content-Type: text/plain");
}

$response = array();
$response["method"] = $_SERVER["REQUEST_METHOD"];
$uri = str_replace(dirname($_SERVER["SCRIPT_NAME"]) . "/", "",
    parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH));
if ($uri)
{
    $response["url"] = explode("/", $uri);
}
else
{
    $response["url"] = array();
}
$response["headers"] = getallheaders();
$response["cookies"] = $_COOKIE;
$response["get"] = $_GET;
$response["post"] = $_POST;
$response["body"] = file_get_contents("php://input");

echo(json_encode($response));
?>