2. Agenda
HTTP1.1
Introduction
Request
Request methods
Response
Problems and workarounds
HTTP2
Two words about SPDY
Concepts
Important things
3. 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.
4. Let’s look at the simple request
GET /index.php HTTP1.1
Host: astoundcommerce.com
Method Request URI HTTP version
Request header(s)
5. Other request headers
Name Description Example
Accept
Content-Types that are acceptable for
the response
Accept: text/plain
Accept-Charset Character sets that are acceptable Accept-Charset: utf-8
Accept-Encoding List of acceptable encodings
Accept-Encoding: gzip,
deflate
Cookie
An HTTP cookie previously sent by the
server with Set-Cookie
Cookie: $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)
7. GET
The GET method means retrieve whatever information (in the form of
an entity) is identified by the Request-URI.
HEAD
The 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.
8. 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.
9. OPTIONS
The OPTIONS method represents a request for information about the
communication options available on the request/response chain
identified by the Request-URI.
TRACE
The TRACE method is used to invoke a remote, application-layer loop-
back of the request message.
CONNECT
This specification reserves the method name CONNECT for use with a proxy that
can dynamically switch to being a tunnel.
10. It’s time to response
HTTP version Response code
Headers
Response body
11. 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
12. Response headers
Name Description Example
Content-Type
The MIME type of this
content
Content-Type: text/html;
charset=utf-8
Date
The 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-Length
The length of the response
body in octets
Content-Length: 348
14. 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.
15. 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
19. 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.
20. “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;
}
22. 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.
23. 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.
24. 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.
25. 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.
26. 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.
27. 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.