You can recover all this information in PHP. It is not available in a file as stated by "please delete my account". In the image, you have a request via POST, the headers and in the body all the information sent.
In the requisition...
To recover the type of request along with the headers you can do this:
$string = $_SERVER['REQUEST_METHOD']."\n"; // pega o tipo de requisição
# pega e armazena todos os cabeçalhos
foreach(getallheaders() as $nome => $valor)
$string .= $nome." : ".$valor."\n";
It will look something like what’s in your image.
To catch the body you can use the $_REQUEST
to get everything($_GET, $_POST, $_COOKIE) that was sent.
Would look like this:
$string = $_SERVER['REQUEST_METHOD']."\n";
foreach(getallheaders() as $nome => $valor)
$string .= $nome." : ".$valor."\n";
$string .= "Body:\n";
foreach($_REQUEST as $key => $value)
$string .= $key." : ".$value."\n";
In response...
In the answer, you can urilize the http_response_code()
, that when it is not entered in the parameter with the response type, it returns the current server response.
And to get all the headers sent by the server, you can use the get_headers()
that even sends the response status.
The body of the answer is with you... It can be an html, xml, a "hello world!" anything displayed, or nothing. And you can recover in various ways as with the file_get_contents()
if this response has a status 200, that is, if there are no errors.
It would be important to contextualize the problem you are trying to solve. Possible is, because thousands of tools implement this, now what is your need in this specific case?
– echojn
@Julianonunes does not have a specific context is more a curiosity than a problem
– Costamilam
Then let’s do it. The request itself is not saved in text file, what happens is that you get via some network Sniffer or even through your browser view the traffic of your machine and get this information. Making the request via Postman is also possible. If you are on a web server for example, you can track all the requests that are being made. Anyway, there are several ways to do it, but since your question is very open it is difficult to know which direction to point you.
– echojn
@Julianonunes I’m not sure if you understand, the idea is that my PHP backend can recover this string, not the browser or third-party software (except libs/frameworks PHP)
– Costamilam