ee 122: lecture 21 (hypertext transfer protocol - http) ion stoica nov 20, 2001 (*)

26
EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

Upload: emory-riley

Post on 19-Jan-2016

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

EE 122: Lecture 21(HyperText Transfer Protocol

- HTTP)

Ion Stoica

Nov 20, 2001

(*)

Page 2: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 2

Background

World Wide Web (WWW): a set of cooperating clients and servers that communicate through HTTP

HTTP history- First HTTP implementation - 1990

• Tim Berners-Lee at CERN

- HTTP/0.9 – 1991

• Simple GET command for the Web

- HTTP/1.0 –1992

• Client/Server information, simple caching

- HTTP/1.1 - 1996

Page 3: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 3

Basics

Client-server architecture Synchronous request/reply protocol Stateless Uses unicast Implemented on top of TCP/IP

Page 4: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 4

Terminology

Resource – file or service (e.g., dynamic results from the execution of a script)

Entity – information transferred in a request or response

Entity Tag – unique identifier for a resource

Page 5: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 5

Universal Resource Locator

An address or location of a resource, e.g., http://www.eecs.berkeley.edu/index.html

Prefix up to “:” represents the protocol to be used to obtain the resource

Page 6: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 6

Client Request

Steps to get the resource: http://www.eecs.berkeley.edu/index.html 1. Use DNS to obtain the IP address of

www.eecs.berkeley.edu, A

2. Send to A an HTTP request:

3. Server response: (see next slide)

GET /index.html HTTP/1.0

Page 7: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 7

Server Response

HTTP/1.0 200 OKContent-Type: text/htmlContent-Length: 1234Last-Modified: Mon, 19 Nov 2001 15:31:20 GMT<HTML><HEAD><TITLE>EECS Home Page</TITLE></HEAD>…</BODY></HTML>

Page 8: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 8

Big Picture

Client ServerTCP Syn

TCP syn + ack

TCP ack + HTTP GET

...

Establishconnection

Requestresponse

Client request

Closeconnection

Page 9: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 9

Request Methods

GET – transfer resource from given URL HEAD – GET resource metadata (headers) only PUT – store/modify resource under the given

URL DELETE – remove resource POST – provide input for a process identified by

the given URL (usually used to post CGI parameters)

Page 10: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 10

Response Codes

1x informational 2x success 3x redirection 4x client error in request 5x server error; can’t satisfy the request

Page 11: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 11

HTTP/1.0 Example

Client Server

Request image 1

Transfer image 1

Request image 2

Transfer image 2

Request text

Transfer text

Finish displaypage

Page 12: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 12

HHTP/1.0 Performance

Create a new TCP connection for each resource- Large number of embedded objects in a web page

- Many short lived connections

TCP transfer- Too slow for small object

- May never exit slow-start phase

Page 13: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 13

Web Proxies

Intermediaries between client and server

Client 1

Proxy Proxy Server

Client 2

Client N

...

Page 14: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 14

Web Proxies (cont’d)

Location: close to the server, client, or in the network

Functions:- Filter requests/responses

- Modify requests/responses

• Change http requests to ftp requests

• Change response content, e.g., transcoding to display data efficiently on a Palm Pilot

- Provide better privacy

- Caching

Page 15: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 15

HTTP/1.0 Caching

A request directive: - Pragma: no-cache – ignore all caches and get resource

directly from server

A modifier to the GET request:- If-modified-since – return a “not modified” response if

resource was not modified since specified time

A response header:- Expires – specify to the client for how long it is safe to

cache the resource

Page 16: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 16

HTTP/1.1

Performance: - Persistent connections

- Pipelined requests/responses

- Chunked transfer encoding

- Compression of data types

- …

Support for virtual hosting Efficient caching support

Page 17: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 17

Persistent Connections

Allow multiple transfers over one connection Avoid multiple TCP connection setups Avoid multiple TCP slow starts

Page 18: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 18

Pipelined Requests/Responses

Buffer requests and responses to reduce the number of packets

Multiple requests can be contained in one TCP segment

Note: order of responses has to be maintained

Client Server

Request 1Request 2Request 3

Transfer 1

Transfer 2

Transfer 3

Page 19: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 19

Chunked Transfer Encoding

In HTTP/1.0 server indicate the end of dynamic content by closing connection

- Persistent connections not possible! Why?

In HTTP/1.1 server splits dynamic content in chunks

Size of chunk in hex followed by semicolon- Dynamic content transfer: series of chunks followed by

a chunk of size 0

Page 20: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 20

Compression of Data Types

Enables transport compression of data types to decrease payload size

Example:- Server sends in response: “Content-Encoding: gzip”

- Client sends: “Accept-Encoding:gzip”

Page 21: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 21

Support for Virtual Hosting

Problem: recall that a request to get http://www.foo.com/index.html has in its header only:

- GET /index.html HTTP/1.0

It is not possible to run two web servers at the same IP address, because GET is ambiguous

- This is useful when outsourcing web content, i.e., company “foo” asks company “outsource” to manage its content

HTTP/1.1 addresses this problem by mandating “Host” header line, e.g.,

GET /index.html HTTP/1.1Host: www.foo.com

Page 22: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 22

HTTP/1.1 - Caching

HTTP/1.1 provides better support for caching- Separate “what to cache” and “whether a cache

response can be used safely”

- Allow server to provide more info on resource cacheability

- A cache does not return unknowingly a stale resources

- Not depending on absolute timestamps

Page 23: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 23

HTTP/1.1 - Caching (cont’d)

Four new headers associated to caching: age header, entity tags, cache-control, and vary

Age Header – the amount of time that is known to have passed since the response message was retrieved

Entity tags – unique tags to differentiate between different cached versions of the same resource

Page 24: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 24

HTTP/1.1 - Caching (cont’d)

Cache-Control- no-cache: get resource only from server

- only-if-cached: obtain resource only from cache

- no-store: don’t allow caches to store request/response

- max-age: response’s should be no grater than this value

- max-stale: expired response OK but not older than staled value

- min-fresh: response should remain fresh for at least stated value

- no-transform: proxy should not change media type

Page 25: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 25

HTTP/1.1 – Caching (cont’d)

Vary - Accommodate multiple representations of the same resource

- Used to list a set of request headers to be used to select the appropriate representation

Example:- Server sends the following response

- Request will contain:

- Cache return the response that has:

HTTP/1.1 200 OK…Vary: Accept-Language

Accept-Language: en-us

Accept-Language: en-us

Page 26: EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)

[email protected] 26

Summary

HTTP the backbone of WWW’ Evolution of HTTP has concentrated on

increasing the performance Next generations (HTTP/NG) concentrate on

increasing extensibility