Application Layer in the Internet The World Wide Web: HTTP The - - PDF document

application layer in the internet
SMART_READER_LITE
LIVE PREVIEW

Application Layer in the Internet The World Wide Web: HTTP The - - PDF document

Application Layer in the Internet The World Wide Web: HTTP The World Wide Web: HTTP 15 February, 2001 1 The World Wide Web


slide-1
SLIDE 1

1

15 February, 2001 1

Application Layer in the Internet

The World Wide Web: HTTP The World Wide Web: HTTP

2 15 February, 2001 The Computer Communications Course

The World Wide Web

slide-2
SLIDE 2

2

3 15 February, 2001 The Computer Communications Course

Uniform Resource Locators (URLs)

  • http://www.cs.huji.ac.il/index.html

4 15 February, 2001 The Computer Communications Course

Overview of HTTP

HTTP: HTTP: HyperText HyperText Transfer Protocol Transfer Protocol

✁ ✁

WWW WWW

s

s application layer protocol application layer protocol

✁ ✁

client/server model client/server model

  • client:

client: browser that requests, browser that requests, receives, receives,

displays

displays

WWW

WWW

  • bjects
  • bjects
  • server:

server: WWW server sends WWW server sends

  • bjects in response to requests
  • bjects in response to requests
✁ ✁

HTTP defines the structure of the HTTP defines the structure of the messages and messages and rools rools of the message

  • f the message

exchange exchange

✂☎✄✝✆✟✞✡✠☎✠☎☛ ✠✟☞ ✌✎✍✑✏✎✒ ✓✔✆✖✕✑✆ ✗ ✕✑✆✙✘✟✕✑✆ ✆✟✞✡✠☎✠☎☛ ✠✚☞ ✛✜✄ ✗✣✢✥✤ ✕✑✦ ✧ ✕✑✆✙✘✟✕✑✆ ★✪✩✬✫✭✆✚✞✡✠✮✠☎☛ ✠✚☞ ✛✯✩☎✘✬☛ ☞✮✩☎✰✟✓✡✆ ✱✳✲ ✲ ✴✶✵ ✷✮✸✮✹ ✷✚✺ ✲ ✻✳✼ ✼✾✽❀✿❂❁ ❃❅❄ ❁ ❆ ✼ ❇✳❈ ❈ ❉✶❊ ❋✚● ❉✑❍❂■
❏▲❑ ❑✾▼❀◆✚❖ P ▼✬◗✾❘ P ❖
slide-3
SLIDE 3

3

5 15 February, 2001 The Computer Communications Course

Underlying Transport Service

http: TCP transport service: http: TCP transport service:

✁ ✁

client initiates TCP connection client initiates TCP connection (creates socket) to server, port 80 (creates socket) to server, port 80

✁ ✁

server accepts TCP connection server accepts TCP connection from client from client

✁ ✁

http messages (application-layer http messages (application-layer protocol messages) exchanged protocol messages) exchanged between browser (http client) and between browser (http client) and WWW server (http server) WWW server (http server)

✁ ✁

TCP connection closed TCP connection closed http is http is

stateless

stateless

server maintains no server maintains no information about past information about past client requests client requests

Protocols that maintain Protocols that maintain

state

state

are

are complex! complex!

  • past history (state) must be

past history (state) must be maintained maintained

  • if server/client crashes, their views

if server/client crashes, their views

  • f
  • f

state

state

may be inconsistent,

may be inconsistent, must be reconciled must be reconciled

6 15 February, 2001 The Computer Communications Course

Reliable Data Transfer

  • .

.

slide-4
SLIDE 4

4

7 15 February, 2001 The Computer Communications Course

HTTP example

Suppose user enters URL Suppose user enters URL www. www.someSchool someSchool. .edu edu/ /someDepartment someDepartment/home.index /home.index 1a.

  • 1a. http client initiates TCP

http client initiates TCP connection to http server connection to http server (process) at (process) at www. www.someSchool someSchool. .edu edu. . Port 80 Port 80 is default for http server. is default for http server. 2.

  • 2. http client sends http

http client sends http request request message message (containing URL) into (containing URL) into TCP connection socket TCP connection socket 1b.

  • 1b. http server at host

http server at host www. www.someSchool someSchool. .edu edu waiting waiting for TCP connection at port 80. for TCP connection at port 80.

  • accepts

accepts

connection, notifying

connection, notifying client client 3.

  • 3. http server receives request

http server receives request message, forms message, forms response response message message containing requested containing requested

  • bject
  • bject

( (someDepartment someDepartment/home.index /home.index), ), sends message into socket sends message into socket

  • (contains text, references

to 10 jpeg images)

8 15 February, 2001 The Computer Communications Course

HTTP example (cont.)

  • non-persistent connection:

non-persistent connection: one object in each TCP connection

  • ne object in each TCP connection
  • some browsers create multiple TCP connections

some browsers create multiple TCP connections simultaneously simultaneously -

  • ne per object
  • ne per object
  • persistent connection:

persistent connection: multiple objects transferred within one TCP multiple objects transferred within one TCP connection connection 5.

  • 5. http client receives response

http client receives response message containing html file, message containing html file, displays html. Parsing html file, displays html. Parsing html file, findis10 referenced jpeg objects findis10 referenced jpeg objects 6.

  • 6. Steps 1-5 repeated for each of 10 jpeg

Steps 1-5 repeated for each of 10 jpeg

  • bjects
  • bjects

4.

  • 4. HTTP server closes TCP connection

HTTP server closes TCP connection.

.

slide-5
SLIDE 5

5

9 15 February, 2001 The Computer Communications Course

Persistent vs Non-persistent Connections

  • .

10 15 February, 2001 The Computer Communications Course

Pipelining

slide-6
SLIDE 6

6

11 15 February, 2001 The Computer Communications Course

HTTP Message Format: Request

✁ ✁

two types of http messages: two types of http messages: request request, , response response

✁ ✁

http request message: http request message:

  • ASCII (human-readable format)

ASCII (human-readable format) GET /labs/index.html HTTP/1.1 Host: www.cs.huji.ac.il Connection: close User-agent: Mozilla/4.0 Accept: text/html, image/gif,image/jpeg Accept-language:fr (extra carriage return, line feed)

  • 12

15 February, 2001 The Computer Communications Course

HTTP Request Messages

Method Method Description Description GET GET Request to read a Web page Request to read a Web page HEAD HEAD Request to read a Web page Request to read a Web page

s header

s header PUT PUT Request to store a Web page Request to store a Web page POST POST Append to a named resource Append to a named resource DELETE DELETE Remove the Web page Remove the Web page LINK LINK Connect two existing resources Connect two existing resources UNLINK UNLINK Break an existing connection between Break an existing connection between two resources two resources

slide-7
SLIDE 7

7

13 15 February, 2001 The Computer Communications Course

General Format of a Request Message

method space URL space Version cr lf

Request line

Header field name : Value cr lf Header field name : Value cr lf cr lf Header lines Entity Body

14 15 February, 2001 The Computer Communications Course

HTTP Message Format: Response

HTTP/1.1 200 OK Date: Tue, 26 Sep 2000 16:10:21 GMT Server: Apache/1.3.9 (Unix) Last-Modified: Thu, 27 Apr 2000 13:06:05 GMT Accept-Ranges: bytes Content-Length: 2774 Connection: close Content-Type: text/html

  • (data data data data data data data ... )
slide-8
SLIDE 8

8

15 15 February, 2001 The Computer Communications Course

General Format of a Response Message

version space Status code space phrase cr lf

Status line

Header field name : Value cr lf Header field name : Value cr lf cr lf Header lines Entity Body

16 15 February, 2001 The Computer Communications Course

HTTP Reply Status Codes

200 OK 200 OK

  • request succeeded, requested object later in this message

request succeeded, requested object later in this message 301 Moved Permanently 301 Moved Permanently

  • requested object moved, new location specified later in this

requested object moved, new location specified later in this message (Location:) message (Location:) 400 Bad Request 400 Bad Request

  • request message not understood by server

request message not understood by server 404 Not Found 404 Not Found

  • requested document not found on this server

requested document not found on this server 505 HTTP Version Not Supported 505 HTTP Version Not Supported In first line in server->client response message. In first line in server->client response message. A few sample codes: A few sample codes:

slide-9
SLIDE 9

9

17 15 February, 2001 The Computer Communications Course

Trying out HTTP (Client Side) for Yourself

  • 1. Telnet to your favorite WWW server:
  • 1. Telnet to your favorite WWW server:
  • telnet www.cs.huji.ac.il 80
  • 2. Type in a GET http request
  • 2. Type in a GET http request:

:

GET /labs/index.html HTTP/1.0

  • 3. Look at response message sent by http server!
  • 3. Look at response message sent by http server!

18 15 February, 2001 The Computer Communications Course

User-server Interaction: Authentication

Authentication goal: Authentication goal: control access to control access to server documents server documents

  • stateless:

stateless: client must present client must present authorization in each request authorization in each request

  • authorization: typically name,

authorization: typically name, password password

  • authorization:

authorization: header line header line in request in request

  • if no authorization presented,

if no authorization presented, server refuses access, sends server refuses access, sends WWW authenticate: WWW authenticate: header line in response header line in response

  • WWW authenticate:
  • Authorization:line
  • Authorization:line
slide-10
SLIDE 10

10

19 15 February, 2001 The Computer Communications Course

User-server Interaction: Cookies

  • server sends

server sends

cookie

cookie

to client in

to client in response response Set-cookie: # Set-cookie: #

  • client present cookie in later

client present cookie in later requests requests cookie: # cookie: #

  • server matches presented-

server matches presented- cookie with server-stored cookie with server-stored cookies cookies

  • authentication

authentication

  • remembering user

remembering user preferences, previous preferences, previous choices choices

  • Set-cookie: #
  • cookie: #
  • cookie: #
  • 20

15 February, 2001 The Computer Communications Course

Web Caching and Conditional GET

slide-11
SLIDE 11

11

21 15 February, 2001 The Computer Communications Course

Web Caching and Conditional GET

✁ ✁

Goal: Goal: don don

t send object if

t send object if client has up-to-date stored client has up-to-date stored (cached) version (cached) version

✁ ✁

client: specify date of cached client: specify date of cached copy in http request copy in http request If-modified-since: If-modified-since: <date> <date>

✁ ✁

server: response contains no server: response contains no

  • bject if cached copy up-to-
  • bject if cached copy up-to-

date: date: HTTP/1.0 304 Not HTTP/1.0 304 Not Modified Modified

  • If-modified-since:

<date>

  • HTTP/1.0

304 Not Modified

  • If-modified-since:

<date>

  • HTTP/1.1 200 OK

<data>

  • 22

15 February, 2001 The Computer Communications Course

HTML Forms

slide-12
SLIDE 12

12

23 15 February, 2001 The Computer Communications Course

Common Gateway Interface (CGI)

  • GET http://www.google.com/ HTTP/1.0
  • file index.html with HTML form
  • GET http://www.google.com/search?q=CGI HTTP/1.0
  • html file with the CGI script output

Fill the form, click on“Submit” Run specified script with specified args

24 15 February, 2001 The Computer Communications Course

Further Info Sources

✁ ✁

RFC 1945 (HTTP/1.0) RFC 1945 (HTTP/1.0)

✁ ✁

RFC 2616 (HTTP/1.1) RFC 2616 (HTTP/1.1)