Uncategorized

A Quick Reference To HTTP

HTTP 0.9 Protocol:

  • Defined in 1991
  • Latency is not at all a factor in HTTP 0.9
  • In order to perform an http request client has to open a new TCP connection which is closed by server after responding to it.
  • HTTP 0.9 User 3 way hand shake mechanism to establish a connection
  • Its s simple text based protocol
  • Only GET Method is allowed and Response Is HTML
  • No Headers and Status Codes
  • Invented by Tim Berners-lee at CERN
  • Need a TCP connection for each Request

TCP 3 way Handshake:

HTTP 0.9 using telnet

HTTP 1.0 Protocol:

  • Introduced in 1996
  • HEAD and POST Methods were added
  • Concept of header fields are introduced
  • User-Agent introduced in Request (for debugging purpose)
  • Content-Length introduced in Response (to identify the proper response)
  • Caching , Authorization etc
  • Still it Needs a TCP connection for each Request
  • Status Codes are introduced
  • Non-HTML can also be transmitted over this protocol

Telnet Using HTTP 1.0:

HTTP 1.1 Protocol:

  • Published om 1997
  • Persistent Connection Introduced
  • The same connection can be used for consecutive request for single embedded documents like images etc.
  • Chunked Responses were supported
  • HOST header has been introduced. This allowed hosting different domains from same IP address
  • Content Negotiation, encoding and type are introduced.
  • GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS

Telnet Using HTTP 1.1

Keep-alive Header:

 This header allowed the connection to be opened for some time

Keep-Alive: timeout=600,max100

Connection: Keep-Alive

 

Telnet Using Keep Alive HTTP 1.1

HTTP/2 protocol:

  • Started in 2015
  • Http2 is a binary, multiplexed, network protocol
  • Frames and streams are used to communicate using this protocol
  • Frames are exchanged over TCP connection instead of text based messages. The following frame types are available.
  • HEADERS, DATA,SETTINGS, or GOAWAY are different frame types.

There are two ways to use http2 protocol

  1. Using upgrade header
    1. Send an http connection with upgrade header

GET /index.html HTTP/1.1

Host: server.example.com

Connection: Upgrade, HTTP2-Settings

Upgrade: h2c

HTTP2-Settings: <base64url encoding of HTTP/2 SETTINGS payload>

  1. Http 2 compatible server will accept the connection with switching protocols.

HTTP/1.1 101 Switching Protocols

Connection: Upgrade

Upgrade: h2c

[ HTTP/2 connection …

ALPN: Application level Protocol Negotiation:

ALPN allows a TLS connection to negotiate which application level will be running across it.

After establishing an HTTP/2 connection each endpoint has to send a connection preferences as a final confirmation and to establish the initial settings for http2 connection.

CURL Using HTTP 2.0

Here is the code rut a jetty server with http2 protocol

https://github.com/prabhukvn/springboot-jetty-http2

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s