Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does HTTP look like?

I've been working a lot with HTTP related things - HTTP requests, HTTP responses, HTTP methods etc., but I'm not really sure I understand what the protocol itself looks like. Is it a document like a specification?

like image 601
Emanuil Rusev Avatar asked Dec 21 '22 09:12

Emanuil Rusev


2 Answers

Hyper Text Transfer Protocol (HTTP) provides a pattern to interact with Resources (e.g. webpages on a webserver). Essentially it boils down to a Request (typically from a browser) and a Response (typically from a webserver).

HTTP visualization

The request highlighted red above identifies an action verb such as GET, POST, DELETE, or PUT (there are others verbs too) and a resource (URI/URL) to preform the action on. The request above depicts a browser request to view the wikipedia main page.

The server then responds to the request with the blue and green sections above; they represent the response header and the response body. The response header contains a lot of optional information about the server but the important fields are the status code (200 OK), the content length (54218) and the content type (text/html).

Since the content type is html the browser will try to render the html inside the response body. If the content type were something else such as a word doc then the browser would probably open a save dialog box. There are a plethora of content types that the body could represent, but not all browsers support each of the content types.

like image 200
Darwyn Avatar answered Dec 24 '22 01:12

Darwyn


Is it a document like a specification?

Yes, HTTP is a protocol over TCP/IP defined in the following specification: http://www.w3.org/Protocols/rfc2616/rfc2616.html

This protocol is for example implemented by web servers and client browsers.

like image 30
Darin Dimitrov Avatar answered Dec 24 '22 02:12

Darin Dimitrov