Here’s an excerpt from a Wikipedia article:
In contrast to the GET request method where only a URL and headers are
sent to the server, POST requests also include a message body.
Based on that, it looks like the URL is sent separately from the header, but if that’s so, why do we use the header() method in PHP to set a URL to redirect to?
header("Location: http://google.com");
When you want to browse an URL from your browser you type an URL. The browser puts the url inside an HTTP REQUEST like this:
Then a webserver gives you an answer like this:
Every line like this “Header-Name: header_value\r\n” is an header.
PHP header function adds an header to the response before sending it to user’s browser.
In your example the header is:
And it’s added just after the last header before the “empty line” (which is a line which contains only a \r\n).
POST requests are different from GET requests because you have a request body after the “empty line”):
In conclusion an HTTP request is made like this:
PS. Rows are ALWAYS closed by “\r\n” bytes (“empty lines” are made of just those two bytes).