Simple PHP HTTP Requests Echo Server

Sometimes you just need to see what you are sending as part of your HTTP request, to make sure the wrappers and the libraries you are using are not malfunctioning.
A simple echo server is very useful for this.

Here is a very simple one, which works with Apache Webserver and it prints out the raw Body of request.

Hope it will help someone.

$headers = apache_request_headers();
echo "-- Headers --<br/>\n";
foreach ($headers as $header => $value)
{
    echo "$header: $value <br />\n";
}
// Printing out the Body of the Request
echo "-- Body -- <br/>\n";
$raw_input = file_get_contents('php://input');
print_r($raw_input);
Advertisements