What is HTTP
-
Client-server/Request-Response protocol. Default port 80, other can be
used. Uses TCP, does not use UDP. Google’s QUIC uses HTTP over UDP
HTTP Clients: Web-browser, Any process can create socket and get information from server.
Features of HTTP
-
1. CONNECTIONLESS: HTTP-client(browser) initiates an HTTP request and
after a request is made, the client disconnects from the server and
waits for a response. server processes the request and re-establishes
the connection with the client to send a response back.
2. MEDIA INDEPENDENT: Any type of data can be sent by HTTP as long as both the client and the server know how to handle the data content.
3. STATELESS: No session information is stored either by client or server.
4. Persistant & Parallel Connection: 2 access requests can be sent back-2-back without waiting for response to arrive.
Client Server
<-----TCP-3-way-handshake---->
--------GET Page-1----------->
--------GET Page-2----------->
<-------Page-1---------------
<-------Page-2---------------
Advatanges, Disadvatanges/pitfalls of HTTP
Advatanges
-
1. Flexible. Whenever there are additional capabilities needed by an
application, HTTP has the capability to extend. These can include Flash
players and Acrobat reader.
2. Less connections. With HTTP2 and HTTP3 multiple requests can be sent in 1 packet.
3. Network BW: Less dues to less connections as HTTP2, HTTP3 sends multiple requests in 1 connection.
4. Error reporting: Reports errors without closing the TCP connection.
DisAdvatanges
-
1. Can only be used for point to point connection.
2. Does not have push capabilities as in [Long Pooling or server sent Events](/Networking/OSI-Layers/Layer5/WebServer_to_WebClient_Connection_Methods).
3. HTTPv2 does not offer reliable exchange (without retry logic).
HTTP Methods
-
Method / Operations Methods for requesting web page or
content.
Safe methods? Those which donot change state of server. Eg: GET, HEAD
Read only methods? GET, OPTIONS, HEAD
Idempotent methods? A operation that will produce the same results if executed once or multiple times. Eg: GET, HEAD, PUT, DELETE, TRACE, OPTIONS
CRUD Operations: Protocol should support minimum these operations/methods.
Method | Description |
---|---|
Create (POST) | Send data to server, Server will create entry. Eg: Form submittion. |
Read (GET) |
Reading data(page,object etc) from web server
|
Update (PUT) | Update existing data on web server. |
Delete (DELETE) | Delete content from server |
HEAD |
Requests only the headers of a resource, not the body Server responds with headers (including metadata, content-type, length, status codes, etc.), but no content. Why its helpful? check what a GET request would return, without actually downloading the resource (useful for checking file size, last-modified, existence, etc.)
|