Files
cws/notes/http-request.md
2024-11-26 17:16:04 +01:00

662 B

HTTP Request

This is an example of a basic HTTP request made from the browser:

GET / HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.tutorialspoint.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

Thanks tutorialspoint

The first line is a request line. It has:

  • Method (GET, POST, HEAD, ...)
  • Location (the request resource, file)
  • HTTP version

HTTP Response

HTTP/1.1 200 OK\r\n
Content-Type: text/html\r\n
Content-Length: 88\r\n
Connection: Closed\r\n
\r\n
<HTML>

Content-Length is the length of the body (in the response case is the length of html page)