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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s