Skip to content

Instantly share code, notes, and snippets.

@pjdietz
Last active December 25, 2015 00:59
Show Gist options
  • Save pjdietz/6892064 to your computer and use it in GitHub Desktop.
Save pjdietz/6892064 to your computer and use it in GitHub Desktop.
Test an HTTP request. Respond with information about the request.
<?php
// Return information about the request sent to this script.
$request = array(
'protocol' => $_SERVER['SERVER_PROTOCOL'],
'method' => $_SERVER['REQUEST_METHOD'],
'host' => $_SERVER['HTTP_HOST'],
'path' => $_SERVER['REQUEST_URI'],
'queryString' => $_SERVER['QUERY_STRING'],
'headers' => apache_request_headers(),
'queryFields' => $_GET,
'formFields' => $_POST,
'body' => file_get_contents("php://input")
);
header('Content-type: application/json');
print json_encode($request);
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment