Presentation is loading. Please wait.

Presentation is loading. Please wait.

How HTTP Works Made by Manish Kushwaha.

Similar presentations


Presentation on theme: "How HTTP Works Made by Manish Kushwaha."— Presentation transcript:

1 How HTTP Works Made by Manish Kushwaha

2 How do computers communicate via the Internet?
HTTP is the protocol that web browsers and web servers use to communicate with each other over the Internet. It is an application layer protocol. HTTP is a connectionless text based protocol. Clients (web browsers) send requests to web servers for web elements such as web pages and images. After the request is serviced by a server, the connection between client and server across the Internet is disconnected. A new connection must be made for each request.

3 HTTP and connections A connection is controlled at the transport layer, and therefore fundamentally out of scope for HTTP. Though HTTP doesn't require the underlying transport protocol to be connection-based; only requiring it to be reliable, or not loose messages (so at minimum presenting an error). Among the two most common transport protocols on the Internet, TCP is reliable and UDP isn't. HTTP subsequently relies on the TCP standard, which is connection-based, even though a connection is not always required. HTTP/1.0 opened a TCP connection for each request/response exchange, introducing two major flaws: opening a connection needs several round-trips of messages and therefore slow, but becomes more efficient when several messages are sent, and regularly sent: warm connections are more efficient than cold ones. In order to mitigate these flaws, HTTP/1.1 introduced pipelining (which proved difficult to implement) and persistent connections: the underlying TCP connection can be partially controlled using the Connection header. HTTP/2 went a step further by multiplexing messages over a single connection, helping keep the connection warm, and more efficient. Experiments are in progress to design a better transport protocol more suited to HTTP. For example, Google is experimenting with QUIC which builds on UDP to provide a more reliable and efficient transport protocol.

4

5 HTTP flow When the client wants to communicate with a server, either being the final server or an intermediate proxy, it performs the following steps: Open a TCP connection: The TCP connection will be used to send a request, or several, and receive an answer. The client may open a new connection, reuse an existing connection, or open several TCP connections to the servers. Send an HTTP message: HTTP messages (before HTTP/2) are human-readable. With HTTP/2, these simple messages are encapsulated in frames, making them impossible to read directly, but the principle remains the same. Read the response sent by the server: Close or reuse the connection for further requests.

6 HTTP Messages HTTP/1.1 and earlier HTTP messages are human-readable. In HTTP/2, these messages are embedded into a new binary structure, a frame, allowing optimizations like compression of headers and multiplexing. Even if only part of the original HTTP message is sent in this version of HTTP, the semantics of each message is unchanged and the client reconstitutes (virtually) the original HTTP/1.1 request. It is therefore useful to comprehend HTTP/2 messages in the HTTP/1.1 format. There are two types of HTTP messages, requests and responses, each with its own format. GET / HTTP/1.1 Host: developer.mozilla.org Accept-Language: en HTTP/ OK Date: Sat, 09 Oct :28:02 GMT Server: Apache

7 An example HTTP request
Requests consists of the following elements: An HTTP method, usually a verb like GET, POST or a noun like OPTIONS or HEAD that defines the operation the client wants to perform. Typically, a client wants to fetch a resource (using GET) or post the value of an HTML form (using POST), though more operations may be needed in other cases. The path of the resource to fetch; the URL of the resource stripped from elements that are obvious from the context, for example without the protocol ( the domain (here developer.mozilla.org), or the TCP port (here 80). The version of the HTTP protocol. Optional headers that convey additional information for the servers. Or a body, for some methods like POST, similar to those in responses, which contain the resource sent.

8 An example responses

9 Status Codes 1xx: Informational Messages The server can send a Expect: 100-continue message, telling the client to continue sending the remainder of the request 2xx: Successful 202 Accepted 204 No Content 205 Reset Content 206 Partial Content 3xx: Redirection 301 Moved Permanently 303 See Other 304 Not Modified 4xx: Client Error 400 Bad Request 401 Unauthorized 403 Forbidden 405 Method Not Allowed 409 Conflict 5xx: Server Error 501 Not Implemented 503 Service Unavailable

10 Some Useful HTTP Methods
GET The GET method is used to retrieve information from the given server using a given URI. POST A POST request is used to send data to the server, for example, customer information, file upload, etc. using HTML forms. HEAD Same as GET, but transfers the status line and header section only. PUT Replaces all current representations of the target resource with the uploaded content. DELETE Removes all current representations of the target resource given by a URI. CONNECT Establishes a tunnel to the server identified by a given URI.

11 HTTP Headers HTTP headers allow the client and the server to pass additional information with the request or the response. Headers can be grouped according to their contexts: General header: Headers applying to both requests and responses but with no relation to the data eventually transmitted in the body. Request header: Headers containing more information about the resource to be fetched or about the client itself. Response header: Headers with additional information about the response, like its location or about the server itself (name and version etc.). Entity header: Headers containing more information about the body of the entity, like its content length or its MIME-type.

12 HTTP Header’s Structure

13 What happens when we type URL
If the URL contains a domain name, the browser first connects to a domain name server and retrieves the corresponding IP address for the web server. The web browser connects to the web server and sends an HTTP request for the desired web page. The web server receives the request and checks for the desired page. If the page exists, the web server sends it. If the server cannot find the requested page, it will send an HTTP 404 error message. The web browser receives the page back and the connection is closed. The browser then parses through the page and looks for other page elements it needs to complete the web page. These usually include images, applets, etc. For each element needed, the browser makes additional connections and HTTP requests to the server for each element. When the browser has finished loading all images, applets, etc. the page will be completely loaded in the browser window.

14 HTTP caching The performance of web sites and applications can be significantly improved by reusing previously fetched resources. Web caches reduce latency and network traffic and thus lessen the time needed to display a representation of a resource. Caching: Caching is a technique that stores a copy of a given resource and serves it back when requested. When a web cache has a requested resource in its store, it intercepts the request and returns its copy instead of re-downloading from the originating server. This achieves several goals: it eases the load of the server that doesn’t need to serve all clients itself, and it improves performance by being closer to the client.

15 There are two kinds of caches
Private Caches Dedicated to a single user. Shared Caches Stores responses for reuse by more than one user

16

17 Anatomy of an HTTP Transaction

18 Serial HTTP Connection
A Serial HTTP connection occurs when multiple requests are issued sequentially to a server, and each request establishes a new connection. This method rarely occurs today because all modern browsers support parallel connections to a host

19 Parallel HTTP Transactions
The HTTP 1.1 protocol provides browsers with the ability to open multiple connections and perform HTTP requests in parallel.


Download ppt "How HTTP Works Made by Manish Kushwaha."

Similar presentations


Ads by Google