http1.1/2 overview

29
HTTP1.1/2 SPECIFICATIONS OVERVIEW, METHODS AND IMPORTANT CHANGES Andrew Muntian, March 2015

Upload: andrew-muntian

Post on 15-Jul-2015

300 views

Category:

Technology


0 download

TRANSCRIPT

HTTP1.1/2SPECIFICATIONS OVERVIEW, METHODS AND IMPORTANT CHANGES

Andrew Muntian, March 2015

Agenda

HTTP1.1

Introduction

Request

Request methods

Response

Problems and workarounds

HTTP2

Two words about SPDY

Concepts

Important things

So, what’s HTTP?

The Hypertext Transfer Protocol (HTTP) is an application protocol for

distributed, collaborative, hypermedia information systems.

HTTP is the foundation of data communication for the WWW.

Hypertext is structured text that uses logical links (hyperlinks) between

nodes containing text.

HTTP is the protocol to exchange or transfer hypertext.

Let’s look at the simple request

GET /index.php HTTP1.1

Host: astoundcommerce.com

Method Request URI HTTP version

Request header(s)

Other request headers

Name Description Example

AcceptContent-Types that are acceptable for

the responseAccept: text/plain

Accept-Charset Character sets that are acceptable Accept-Charset: utf-8

Accept-Encoding List of acceptable encodingsAccept-Encoding: gzip,

deflate

CookieAn HTTP cookie previously sent by the

server with Set-CookieCookie: $Version=1;

Skin=new;

User-Agent The user agent string of the user agent

User-Agent: Mozilla/5.0

(X11; Linux x86_64;

rv:12.0)

Request methods

GETThe GET method means retrieve whatever information (in the form of

an entity) is identified by the Request-URI.

HEADThe HEAD method is identical to GET except that the server MUST NOT return a message-body in the response.

The meta-information contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request.

POST

The POST method is used to request that the origin server accept the

entity enclosed in the request as a new subordinate of the resource

identified by the Request-URI in the Request-Line.

DELETE

The DELETE method requests that the origin server delete the resource identified by the Request-URI.

OPTIONSThe OPTIONS method represents a request for information about the communication options available on the request/response chain identified by the Request-URI.

TRACEThe TRACE method is used to invoke a remote, application-layer loop-

back of the request message.

CONNECTThis specification reserves the method name CONNECT for use with a proxy that

can dynamically switch to being a tunnel.

It’s time to responseHTTP version Response code

Headers

Response body

Response codes

1xx Informational

Ex. 101 Switching Protocols

2xx Success

Ex. 200 OK

3xx Redirection

Ex. 304 Not Modified

4xx Client Error

Ex. 404 Not Found

5xx Server Error

Ex. 502 Bad Gateway

Response headers

Name Description Example

Content-TypeThe MIME type of this

content

Content-Type: text/html;

charset=utf-8

DateThe date and time that the

message was sent

Date: Tue, 5 Nov 1994

08:12:31 GMT

Set-Cookie An HTTP cookie

Set-Cookie:

UserID=JohnDoe; Max-

Age=3600; Version=1

Server A name for the server Server: Apache/2.4.1 (Unix)

Content-LengthThe length of the response

body in octets Content-Length: 348

Problems of HTTP1.1

HTTP 1.1 is huge

When HTTP was created and thrown out into the world it was probably

perceived as a rather simple and straightforward protocol, but time

has proved that to be false.

HTTP 1.0 in RFC 1945 is a 60 page specification released in 1996.

RFC 2616 that describes HTTP 1.1 was released only three years later in

1999 and had grown significantly to 176 pages.

Transfer sizes and number of

objects

Over the years the amount of data that needs to be retrieved has

gradually risen up to and above 1.9MB. Average over a hundred

individual resources are required to display each page.

77

100

2011 2015

OBJECTS

725

1900

2011 2015

TRANSFER SIZE (KB)

httparchive.org

Head of line blocking

Workarounds “Spriting”

“Sharding”

Concatenation

A big site can end up with a lot of different JavaScript files.

Front-end tools will help developers merge everyone of them into a

single huge lump so that the browser will get a single big one instead of

dozens of smaller files.

“Inlining”

URLs embedded in the CSS file. This has similar benefits and drawbacks

as the “spriting” case.

.icon1 {

background: url(data:image/png;base64,<data>) no-repeat;

}

.icon2 {

background: url(data:image/png;base64,<data>) no-repeat;

}

HTTP2

SPDY

SPDY (speedy) is a protocol that was developed and spearheaded by

Google.

When the HTTPbis group decided it was time to start working on http2, SPDY had already proven that it was a working concept.

The http2 work then subsequently started off from the SPDY/3 draft that

was basically made into the http2 draft-00 with a little search and

replace.

HTTP2 main concepts

It has to maintain HTTP paradigms;

http:// and https:// URLs cannot be changed;

Proxy HTTP1 servers and clients to HTTP2;

Subsequently, proxies must be able to map HTTP2 features to HTTP 1.1 clients 1:1;

Remove or reduce optional parts from the protocol;

No more minor version.

HTTP2 and TLS

SPDY is only done over TLS and there's been a strong push for making

TLS mandatory for http2 but it didn't get consensus and http2 will ship

with TLS as optional.

However, two prominent implementers have stated clearly that they

will only implement http2 over TLS: the Mozilla Firefox lead and the

Google Chrome lead.

Two of the leading web browsers of today.

Binary

HTTP2 is a binary protocol.

Figuring out the start and the end of frames is one of the really complicated things in HTTP 1.1 and actually in text based protocols in

general.

By moving away from optional white spaces and different ways to

write the same thing, implementations become simpler.

Binary frames

HTTP2 sends binary frames. There are different frame types that can be

sent and they all have the same setup: Type, Length, Flags, Stream

Identifier and frame payload.

Multiplexed streams

The Stream Identifier mentioned in the previous section describing the binary frame format, makes each frame sent over HTTP2 get associated with a “stream”.

Multiplexing the streams means that packages from many streams are mixed over the same connection. Two (or more) individual trains of data are made into a single one and then split up again on the other side.

Thank you!

Bibliography

HTTP1.1 specification (RFC 2616)

http://daniel.haxx.se/http2

Wiki

http://habrahabr.ru/

http://httparchive.org/

https://http2.github.io/