Last active
December 4, 2020 09:36
-
-
Save mpdroog/958bd1c48e23b1f7b7c74c23cd799ab5 to your computer and use it in GitHub Desktop.
Dump HTTP-request for easy debugging if head/body is properly set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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