If you want to view the URL from your browser, enter the URL. The browser puts the URL in the HTTP REQUEST:
GET /path/to/resource.php?var=data1&othervar=data2 HTTP/1.1 Host: example.com Connection: keep-alive "empty line"
Then the web server gives you this answer:
HTTP/1.0 200 OK Date: Fri, 02 Sep 2011 14:37:36 GMT Server: Apache Cache-Control: private, s-maxage=0, max-age=0, must-revalidate Content-Encoding: gzip Vary: Accept-Encoding Content-Length: 149 Content-Type: text/javascript; charset=utf-8 Connection: keep-alive "empty line" "149 bytes of Response data"
Each line of type "Header Header: header_value \ r \ n" is a header.
The PHP header function adds a header to the response before sending it to the user's browser.
In your example, the title:
Location: http:
And it is added immediately after the last heading before the "empty line" (this is a line containing only \ r \ n).
POST requests are different from GET requests because you have the body of the request after the "empty line"):
POST /path/to/resource.php HTTP/1.1 Host: example.com Connection: keep-alive Content-Length: "number of bytes in the body" "empty line" variable=data&othervar=data2
In conclusion, the HTTP request is executed as follows:
- A request / response line (POST or GET followed by the URL and the http version for the request, the Http version with the response code and the response line for the response), ending \ r \ n
- Request / response header (header-name: header_value \ r \ n)
- empty string (\ r \ n)
- Response / Request Body
PS. Lines ALWAYS close with bytes "\ r \ n" ("empty lines" consist of only these two bytes).
source share