Skip to content

Instantly share code, notes, and snippets.

@mpdroog
Last active December 4, 2020 09:36
Show Gist options
  • Save mpdroog/958bd1c48e23b1f7b7c74c23cd799ab5 to your computer and use it in GitHub Desktop.
Save mpdroog/958bd1c48e23b1f7b7c74c23cd799ab5 to your computer and use it in GitHub Desktop.
Dump HTTP-request for easy debugging if head/body is properly set
<?php
/**
* Dump received HTTP-request to console for quickly
* seeing what we're trying to send.
*/
$address = '127.0.0.1';
$port = 8080;
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
socket_bind($sock, $address, $port) or die('Could not bind to address');
echo "\n Listening On port $port For Connection... \n\n";
while(1)
{
socket_listen($sock);
$client = socket_accept($sock);
$input = socket_read($client, 1024);
echo $input;
socket_close($client);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment