web services april 24, 2001 - carnegie mellon school of ... filecs 213 s’01 – 7 – class26....

45
Web services April 24, 2001 Topics HTTP Serving static content Serving dynamic content class26.ppt 15 - 213 “The course that gives CMU its Zip!”

Upload: hoangnhu

Post on 28-Apr-2019

213 views

Category:

Documents


0 download

TRANSCRIPT

Web

ser

vice

sA

pril

24, 2

001

Top

ics

•H

TT

P•

Ser

ving

sta

tic c

onte

nt•

Ser

ving

dyn

amic

con

tent

cla

ss2

6.

pp

t

15-2

13“T

he c

ours

e th

at g

ives

CM

U it

s Z

ip!”

CS

213

S’0

1–

2–

cla

ss2

6.

pp

t

Web

his

tory

1945

: •

Van

neva

rB

ush,

“As

we

may

thin

k”, A

tlant

ic M

onth

ly, J

uly,

194

5.–

Des

crib

es th

e id

ea o

f a d

istr

ibut

ed h

yper

text

sys

tem

.–

a “m

emex

” tha

t mim

ics

the

“web

of t

rails

” in

our m

inds

.

1989

:•

Tim

Ber

ners

-Lee

(CE

RN

) writ

es in

tern

al p

ropo

sal t

o de

velo

p a

dist

ribut

ed h

yper

text

sys

tem

.–

conn

ects

“a w

eb o

f not

es w

ith li

nks”

.–

inte

nded

to h

elp

CE

RN

phy

sici

sts

in la

rge

proj

ects

sha

re a

nd

man

age

info

rmat

ion

1990

:•

Tim

BL

writ

es a

gra

phic

al b

row

ser f

or N

ext m

achi

nes.

CS

213

S’0

1–

3–

cla

ss2

6.

pp

t

Web

his

tory

(con

t)19

92 •N

CS

A s

erve

r rel

ease

d•

26 W

WW

ser

vers

wor

ldw

ide

1993 •

Mar

c A

ndre

esse

nre

leas

es fi

rst v

ersi

on o

f NC

SA

Mos

aic

brow

ser

•M

osai

c ve

rsio

n re

leas

ed fo

r (W

indo

ws,

Mac

, Uni

x).

•W

eb (p

ort 8

0) tr

affic

at 1

% o

f NS

FN

ET

bac

kbon

e tr

affic

.•

Ove

r 200

WW

W s

erve

rs w

orld

wid

e.

1994 •

And

rees

sen

and

colle

ague

s le

ave

NC

SA

to fo

rm "

Mos

aic

Com

mun

icat

ions

Cor

p" (n

ow N

etsc

ape)

.

CS

213

S’0

1–

4–

cla

ss2

6.

pp

t

Inte

rnet

Dom

ain

Sur

vey

(ww

w.i

sc.o

rg)

100

1,00

0

10,0

00

100,

000

1,00

0,00

0

10,0

00,0

00

100,

000,

000

Aug-81 Oct-84 Nov-86 Oct-88 Oct-89

Jul-9

1Apr-9

2 Jan-9

3 Oct-93 Oct-94 Ja

n-96

Jul-9

7 Jan-9

9

Internet hosts

Mos

aic

and

Net

scap

e

CS

213

S’0

1–

5–

cla

ss2

6.

pp

t

Web

ser

vers

web

serv

er

HT

TP

re

qu

est

HT

TP

re

spo

nse

(co

nte

nt)

Clie

nts

and

serv

ers

com

mun

icat

e us

ing

th

e H

yper

Tex

tT

rans

fer

Pro

toco

l (H

TT

P)

•cl

ient

and

ser

ver e

stab

lish

TC

P c

onne

ctio

n•

Clie

nt re

ques

ts c

onte

nt•

Ser

ver r

espo

nds

with

re

ques

ted

cont

ent

•cl

ient

and

ser

ver c

lose

co

nnec

tion

(usu

ally

)

Cur

rent

ver

sion

is

HT

TP

/1.1

•R

FC

261

6, J

une,

199

9.

web

clie

nt(b

row

ser)

CS

213

S’0

1–

6–

cla

ss2

6.

pp

t

Web

ser

ver s

tatis

tics

sour

ce: N

etcr

aft W

eb S

urve

y w

ww

.net

craf

t.com

/sur

vey

Ap

ach

e

Mic

roso

ft

Oth

er

Mo

saic

Ne

tsca

pe

CS

213

S’0

1–

7–

cla

ss2

6.

pp

t

Sta

tic a

nd d

ynam

ic c

onte

ntT

he c

onte

nt re

turn

ed in

HT

TP

resp

onse

s ca

n be

eith

er

stat

ic o

r dyn

amic

.S

tatic

con

tent

: •

cont

ent s

tore

d in

file

s an

d re

trie

ved

in re

spon

se to

an

HT

TP

req

uest

–H

TM

L fil

es–

imag

es–

audi

o cl

ips

Dyn

amic

con

tent

:•

cont

ent p

rodu

ced

on-t

he-f

ly in

resp

onse

to a

n H

TT

P re

ques

t–

Exa

mpl

e: c

onte

nt p

rodu

ced

by a

CG

I pro

cess

exe

cute

d by

the

serv

er o

n be

half

of th

e cl

ient

.

CS

213

S’0

1–

8–

cla

ss2

6.

pp

t

UR

Is a

nd U

RLs

netw

ork

reso

urce

s ar

e id

entif

ied

by U

nive

rsal

R

esou

rce

Indi

cato

rs (

UR

Is)

The

mos

t fam

iliar

is th

e ab

solu

te U

RI k

now

n as

the

HT

TP

UR

L:•

htt

p-

url

= “

htt

p:”

“//

” h

ost

[“:

” p

ort

] [a

bs_

pa

th]

•p

ort

defa

ults

to “8

0”•

ab

s_p

ath

defa

ults

to

“/”

•a

bs_

pa

then

ding

in /

defa

ults

to

…/in

de

x.h

tml

Exa

mpl

es (a

ll eq

uiva

lent

):•

htt

p:/

/ww

w.

cs.

cmu.

ed

u:8

0/in

de

x.h

tml

•h

ttp

://w

ww

.cs

.cm

u.e

du

/ind

ex.

htm

l

•h

ttp

://w

ww

.cs

.cm

u.e

du

CS

213

S’0

1–

9–

cla

ss2

6.

pp

t

HT

TP

/1.1

mes

sage

s

An

HT

TP

mes

sage

is e

ither

a R

eque

st o

r a R

espo

nse:

HT

TP-

me

ssa

ge

= R

eq

ue

st |

Re

spo

nse

Req

uest

s an

d re

spon

ses

have

the

sam

e ba

sic

form

:

ge

ne

ric

-m

ess

ag

e =

sta

rt-

line

*me

ssa

ge

-h

ea

de

rC

RL

F[m

ess

ag

e b

od

y]

sta

rt-

line

= R

eq

ue

st-

line

| S

tatu

s lin

em

ess

ag

e-

he

ad

er

= f

ield

-n

am

e “

:” [

field

va

lue

] C

RL

Fm

ess

ag

e-

bo

dy

=

<e

.g.,

HT

ML

file

>

CS

213

S’0

1–

10–

cla

ss2

6.

pp

t

HT

TP

/1.1

requ

ests

Re

qu

est

= M

eth

od

SP

Re

qu

est

-U

RI

SP

HT

TP

-V

ER

SIO

N C

RL

F

*(g

en

era

l-

he

ad

er

| re

qu

est

-h

ea

de

r | e

ntit

y h

ea

de

r)C

RL

F[

me

ssa

ge

-b

od

y ]

Me

tho

d: t

ells

the

serv

er w

hat o

pera

tion

to p

erfo

rm, e

.g.,

•G

ET:

ser

ve s

tatic

or d

ynam

ic c

onte

nt•

PO

ST:

serv

e dy

nam

ic c

onte

nt•

OP

TIO

NS:

retr

ieve

ser

ver a

nd a

cces

s ca

pabi

litie

s

Re

qu

est

-U

RI:

iden

tifie

s th

e re

sour

ce to

man

ipul

ate

•da

ta fi

le (H

TM

L), e

xecu

tabl

e fil

e (C

GI)

he

ad

ers

: par

amet

eriz

e th

e m

etho

d•

Acc

ep

t-

La

ng

ua

ge

: e

n-

us

•U

ser

-A

ge

nt:

M

ozi

lla/4

.0 (

com

pa

tible

; M

SIE

4.0

1;

Win

do

ws

98

)

me

ssa

ge

-b

od

y: t

ext c

hara

cter

s

CS

213

S’0

1–

11–

cla

ss2

6.

pp

t

HT

TP

/1.1

resp

onse

s

Re

spo

nse

= H

TT

P-

Ve

rsio

n S

P S

tatu

s-

Co

de

SP

Re

aso

n-

Ph

rase

CR

LF

*(g

en

era

l-

he

ad

er

| re

spo

nse

-h

ea

de

r | e

ntit

y h

ea

de

r)C

RL

F[

me

ssa

ge

-b

od

y ]

Sta

tus

cod

e: 3

-dig

it nu

mbe

rR

ea

son

-P

hra

se: e

xpla

natio

n of

sta

tus

code

he

ad

ers

: par

amet

eriz

e th

e re

spon

se•

Dat

e: T

hu, 2

2 Ju

l 199

9 23

:42:

18 G

MT

•S

erve

r: A

pach

e/1.

2.5

BS

DI3

.0-P

HP

/FI-

2.0

•C

onte

nt-T

ype:

text

/htm

l

me

ssa

ge

-b

od

y:

•fil

e

CS

213

S’0

1–

12–

cla

ss2

6.

pp

t

How

ser

vers

inte

rpre

t Req

uest

-UR

IsG

ET

/ H

TT

P/1

.1•

reso

lves

to

ho

me

/htm

l/in

de

x.h

tml

•ac

tion:

retr

ieve

s in

dex.

htm

l

GE

T /

ind

ex.

htm

l HT

TP

/1.1

•re

solv

es to

ho

me

/htm

l/in

de

x.h

tml

•ac

tion:

retr

ieve

s in

de

x.h

tml

GE

T /

foo

.htm

l HT

TP

/1.1

•re

solv

es to

ho

me

/htm

l/fo

o.h

tml

•ac

tion:

retr

ieve

s fo

o.h

tml

GE

T /

cgi

-b

in/t

est

.pl H

TT

P/1

.1•

reso

lves

toh

om

e/c

gi

-b

in/t

est

.pl

•ac

tion:

runs

te

st.p

l

GE

T h

ttp

://e

uro

.e

com

.cm

u.e

du

/ind

ex.

htm

l HT

TP

/1.1

•re

solv

es to

ho

me

/htm

l/in

de

x.h

tml

•ac

tion:

retr

ieve

s in

de

x.h

tml

ho

me

cgi

-b

inh

tml

test

.pl

ind

ex.

htm

lfo

o.h

tml

CS

213

S’0

1–

13–

cla

ss2

6.

pp

t

Exa

mpl

e H

TT

P/1

.1 c

onve

rsat

ion

kitt

yha

wk

> t

eln

et

eu

ro.

eco

m.

cmu.

ed

u8

0C

on

ne

cte

d t

o e

uro

.e

com

.cm

u.e

du

.E

sca

pe

ch

ara

cte

r is

'^]'.

GE

T /

test

.htm

l HT

TP

/1.1

;r

eq

ue

st li

ne

Ho

st:

eu

ro.

eco

m.

cmu.

ed

u

;re

qu

est

h

dr

CR

LF

HT

TP

/1.1

20

0 O

K

;st

atu

s lin

eD

ate

: T

hu

, 2

2 J

ul 1

99

9 0

3:3

7:0

4 G

MT

;r

esp

on

se

hd

rS

erv

er:

Ap

ach

e/1

.3.3

Be

n-

SS

L/1

.28

(U

nix

)L

ast

-M

od

ifie

d:

Th

u,

22

Ju

l 19

99

03

:33

:21

GM

TE

Ta

g:

"48

bb

2-

4f

-3

79

69

10

1"

Acc

ep

t-

Ra

ng

es:

byt

es

Co

nte

nt

-L

en

gth

: 7

9C

on

ten

t-

Typ

e:

text

/htm

lC

RL

F<

htm

l>

;be

gin

nin

g o

f 7

9 b

yte

me

ssa

ge

bo

dy

(co

nte

nt)

<h

ea

d>

<tit

le>

Te

st p

ag

e<

/titl

e>

</h

ea

d>

<b

od

y><

h1

>T

est

pa

ge

</h

1>

</h

tml>

Re

qu

est

se

nt

by

clie

nt

Re

spo

nse

se

nt

by

serv

er

CS

213

S’0

1–

14–

cla

ss2

6.

pp

t

OP

TIO

NS

met

hod

Ret

rieve

s in

form

atio

n ab

out t

he s

erve

r in

gene

ral o

r re

sour

ces

on th

at s

erve

r, w

ithou

t act

ually

retr

ievi

ng

the

reso

urce

.R

eque

st U

RIs

:•

if re

ques

t UR

I = “*

”, th

en th

e re

ques

t is

abou

t the

ser

ver i

n ge

nera

l–

Is th

e se

rver

up?

Is it

HT

TP

/1.1

com

plia

nt?

–W

hat b

rand

of s

erve

r?–

Wha

t OS

is it

runn

ing?

•if

requ

est U

RI !

= “*

”, th

en th

e re

ques

t app

lies

to th

e op

tions

th

at

avai

labl

e w

hen

acce

ssin

g th

at re

sour

ce:

–w

hat m

etho

ds c

an th

e cl

ient

use

to a

cces

s th

e re

sour

ce?

CS

213

S’0

1–

15–

cla

ss2

6.

pp

t

OP

TIO

NS

(eur

o.ec

om)

kitt

yha

wk

> t

eln

et

eu

ro.

eco

m.

cmu.

ed

u8

0T

ryin

g 1

28

.2.2

18

.2..

.C

on

ne

cte

d t

o e

uro

.e

com

.cm

u.e

du

.E

sca

pe

ch

ara

cte

r is

'^]'.

OP

TIO

NS

* H

TT

P/1

.1H

ost

: e

uro

.e

com

.cm

u.e

du

CR

LF

HT

TP

/1.1

20

0 O

KD

ate

: T

hu

, 2

2 J

ul 1

99

9 0

6:1

2:1

1 G

MT

Se

rve

r: A

pa

che

/1.3

.3 B

en

-S

SL

/1.2

8 (

Un

ix)

Co

nte

nt

-L

en

gth

: 0

Allo

w:

GE

T,

HE

AD

, O

PT

ION

S,

TR

AC

E

Re

qu

est

Re

spo

nse

Ho

st is

a

req

uir

ed

he

ad

er

in

HT

TP

/1.1

b

ut

no

t in

H

TT

P/1

.0

CS

213

S’0

1–

16–

cla

ss2

6.

pp

t

OP

TIO

NS

(am

azon

.com

)

kitt

yha

wk

> t

eln

et

am

azo

n.c

om

80

Try

ing

20

8.2

16

.18

2.1

5..

.C

on

ne

cte

d t

oa

ma

zon

.co

m.

Esc

ap

e c

ha

ract

er

is '^

]'.

OP

TIO

NS

/ H

TT

P/1

.0C

RL

FH

TT

P/1

.0 4

05

Be

cau

se I

fe

lt lik

e it

.S

erv

er:

Ne

tsca

pe

-C

om

me

rce

/1.1

2D

ate

: T

hu

rsd

ay,

22

-Ju

l-

99

04

:17

:32

GM

TA

llow

: G

ET

, P

OS

TC

on

ten

t-

typ

e:

text

/pla

in

Re

qu

est

Re

spo

nse

CS

213

S’0

1–

17–

cla

ss2

6.

pp

t

GE

T m

etho

dR

etrie

ves

the

info

rmat

ion

iden

tifie

d by

the

requ

est U

RI.

•st

atic

con

tent

(HT

ML

file)

•dy

nam

ic c

onte

nt p

rodu

ced

by C

GI p

rogr

am–

pass

es a

rgum

ents

to C

GI p

rogr

am in

UR

I

Can

als

o ac

t as

a co

nditi

onal

retr

ieve

whe

n ce

rtai

n re

ques

t hea

ders

are

pre

sent

:•

If-

Mo

difi

ed

-S

ince

•If

-U

nm

od

ifie

d-

Sin

ce

•If

-M

atc

h

•If

-N

on

e-

Ma

tch

•If

-R

an

ge

Con

ditio

nal

GE

Ts

usef

ul fo

r cac

hing

CS

213

S’0

1–

18–

cla

ss2

6.

pp

tGE

T(e

uro.

ecom

.cm

u.e

du)

kitt

yha

wk

> t

eln

et

eu

ro.

eco

m.

cmu.

ed

u8

0C

on

ne

cte

d t

o e

uro

.e

com

.cm

u.e

du

.E

sca

pe

ch

ara

cte

r is

'^]'.

GE

T /

test

.htm

l HT

TP

/1.1

Ho

st:

eu

ro.

eco

m.

cmu.

ed

uC

RL

FH

TT

P/1

.1 2

00

OK

Da

te:

Th

u,

22

Ju

l 19

99

03

:37

:04

GM

TS

erv

er:

Ap

ach

e/1

.3.3

Be

n-

SS

L/1

.28

(U

nix

)L

ast

-M

od

ifie

d:

Th

u,

22

Ju

l 19

99

03

:33

:21

GM

TE

Ta

g:

"48

bb

2-

4f

-3

79

69

10

1"

Acc

ep

t-

Ra

ng

es:

byt

es

Co

nte

nt

-L

en

gth

: 7

9C

on

ten

t-

Typ

e:

text

/htm

lC

RL

F<

htm

l><

he

ad

><

title

>T

est

pa

ge

</t

itle

><

/he

ad

><

bo

dy>

<h

1>

Te

st p

ag

e<

/h1

><

/htm

l>

Re

qu

est

Re

spo

nse

CS

213

S’0

1–

19–

cla

ss2

6.

pp

tGE

Tre

ques

t to

euro

.ec

om(I

nter

net E

xplo

rer b

row

ser)

GE

T /

test

.htm

l HT

TP

/1.1

A

cce

pt:

*/*

A

cce

pt

-L

an

gu

ag

e:

en

-u

s A

cce

pt

-E

nco

din

g:

gzi

p,

de

flate

U

ser

-A

ge

nt:

M

ozi

lla/4

.0 (

com

pa

tible

; M

SIE

4.0

1;

Win

do

ws

98

) H

ost

: e

uro

.e

com

.cm

u.e

du

C

on

ne

ctio

n:

Ke

ep

-A

live

CR

LF

CS

213

S’0

1–

20–

cla

ss2

6.

pp

t

GE

Tre

spon

se fr

om e

uro.

ecom

HT

TP

/1.1

20

0 O

KD

ate

: T

hu

, 2

2 J

ul 1

99

9 0

4:0

2:1

5 G

MT

Se

rve

r: A

pa

che

/1.3

.3 B

en

-S

SL

/1.2

8 (

Un

ix)

La

st-

Mo

difi

ed

: T

hu

, 2

2 J

ul 1

99

9 0

3:3

3:2

1 G

MT

ET

ag

: "4

8b

b2

-4

f-

37

96

91

01

"A

cce

pt

-R

an

ge

s: b

yte

sC

on

ten

t-

Le

ng

th:

79

Ke

ep

-A

live

: tim

eo

ut=

15

, m

ax=

10

0C

on

ne

ctio

n:

Ke

ep

-A

live

Co

nte

nt

-T

ype

: te

xt/h

tml

CR

LF

<h

tml>

<h

ea

d>

<tit

le>

Te

st p

ag

e<

/titl

e>

</h

ea

d>

<b

od

y><

h1

>T

est

pa

ge

</h

1>

</h

tml>

CS

213

S’0

1–

21–

cla

ss2

6.

pp

tGE

Tre

ques

t to

euro

.ec

om

(Net

scap

e br

owse

r)G

ET

/te

st.h

tml H

TT

P/1

.0C

on

ne

ctio

n:

Ke

ep

-A

live

Use

r-

Ag

en

t:

Mo

zilla

/4.0

6 [

en

] (W

in9

8;

I)H

ost

: e

uro

.e

com

.cm

u.e

du

Acc

ep

t: im

ag

e/g

if, im

ag

e/x

-xb

itma

p,

ima

ge

/jpe

g,

ima

ge

/p

jpe

g,

ima

ge

/p

ng

, */

*A

cce

pt

-E

nco

din

g:

gzi

pA

cce

pt

-L

an

gu

ag

e:

en

Acc

ep

t-

Ch

ars

et

: is

o-

88

59

-1

,*,

utf

-8

CR

LF

CS

213

S’0

1–

22–

cla

ss2

6.

pp

t

GE

Tre

spon

se fr

om e

uro.

ecom

HT

TP

/1.1

20

0 O

KD

ate

: T

hu

, 2

2 J

ul 1

99

9 0

6:3

4:4

2 G

MT

Se

rve

r: A

pa

che

/1.3

.3 B

en

-S

SL

/1.2

8 (

Un

ix)

La

st-

Mo

difi

ed

: T

hu

, 2

2 J

ul 1

99

9 0

3:3

3:2

1 G

MT

ET

ag

: "4

8b

b2

-4

f-

37

96

91

01

"A

cce

pt

-R

an

ge

s: b

yte

sC

on

ten

t-

Le

ng

th:

79

Ke

ep

-A

live

: tim

eo

ut=

15

, m

ax=

10

0C

on

ne

ctio

n:

Ke

ep

-A

live

Co

nte

nt

-T

ype

: te

xt/h

tml

CR

LF

<h

tml>

<h

ea

d>

<tit

le>

Te

st p

ag

e<

/titl

e>

</h

ea

d>

<b

od

y><

h1

>T

est

pa

ge

</h

1>

</h

tml>

CS

213

S’0

1–

23–

cla

ss2

6.

pp

t

HE

AD

met

hod

Ret

urns

sam

e re

spon

se h

eade

r as

a G

ET

requ

est w

ould

ha

ve...

But

doe

sn’t

actu

ally

car

ry o

ut th

e re

ques

t and

retu

rns

no c

onte

nt•

som

e se

rver

s do

n’t i

mpl

emen

t thi

s pr

oper

ly•

e.g.

, es

pn.c

om

Use

ful f

or a

pplic

atio

ns th

at•

chec

k fo

r val

id a

nd b

roke

n lin

ks in

Web

pag

es.

•ch

eck

Web

pag

es fo

r mod

ifica

tions

.

CS

213

S’0

1–

24–

cla

ss2

6.

pp

t

HE

AD

(etr

ade

.com

)

kitt

yha

wk

> t

eln

et

etr

ad

e.c

om

80

Try

ing

19

8.9

3.3

2.7

5..

.C

on

ne

cte

d t

o

etr

ad

e.c

om

.E

sca

pe

ch

ara

cte

r is

'^]'.

HE

AD

/ H

TT

P/1

.1H

ost

: e

tra

de

.co

mC

RL

FH

TT

P/1

.0 2

00

OK

Se

rve

r: N

ets

cap

e-

En

terp

rise

/2.0

1-

p1

00

Da

te:

Fri

, 2

3 J

ul 1

99

9 0

3:1

8:5

7 G

MT

Re

qu

est

Sta

rtU

sec

: 7

80

32

8R

eq

ue

stS

tart

Se

c:

93

26

99

93

7A

cce

pt

-ra

ng

es:

byt

es

La

st-

mo

difi

ed

: T

ue

, 2

0 J

ul 1

99

9 0

0:5

9:2

6 G

MT

Co

nte

nt

-le

ng

th:

15

37

0C

on

ten

t-

typ

e:

text

/htm

l

Re

qu

est

Re

spo

nse

CS

213

S’0

1–

25–

cla

ss2

6.

pp

t

HE

AD

(esp

n.c

om)

kitt

yha

wk

> t

eln

et

esp

n.c

om

80

Try

ing

20

4.2

02

.13

6.3

1..

.C

on

ne

cte

d t

o

esp

n.c

om

.E

sca

pe

ch

ara

cte

r is

'^]'.

HE

AD

/ H

TT

P/1

.1H

ost

: e

spn

.co

mC

RL

FH

TT

P/1

.1 3

01

Do

cum

en

t M

ove

dS

erv

er:

Mic

roso

ft-

IIS

/4.0

Da

te:

Fri

, 2

3 J

ul 1

99

9 0

3:2

2:3

2 G

MT

Lo

catio

n:

htt

p:/

/e

spn

.go

.co

m/

Co

nte

nt

-T

ype

: te

xt/h

tml

CR

LF

<h

tml>

Is n

ow

pa

rt o

f th

e h

ttp

://

esp

n.g

o.c

om

se

rvic

e<

br

><

/htm

l>

Mod

ern

brow

sers

tran

spar

ently

conn

ect t

o th

e ne

we

spn

.go

.co

mlo

catio

n

Re

qu

est

Re

spo

nse

CS

213

S’0

1–

26–

cla

ss2

6.

pp

t

PO

ST

met

hod

Ano

ther

tech

niqu

e fo

r pro

duci

ng d

ynam

ic c

onte

nt.

Exe

cute

s pr

ogra

m id

entif

ied

in re

ques

t UR

I (th

e C

GI

prog

ram

).P

asse

s ar

gum

ents

to C

GI p

rogr

am in

the

mes

sage

bod

y•

unlik

e G

ET,

whi

ch p

asse

s th

e ar

gum

ents

in th

e U

RI i

tsel

f.

Res

pond

s w

ith o

utpu

t of t

he C

GI p

rogr

am.

Adv

anta

ge o

ver G

ET

met

hod:

•un

limite

d ar

gum

ent s

ize

Dis

adva

ntag

es:

•m

ore

cum

bers

ome

•ca

n’t s

erve

sta

tic c

onte

nt

CS

213

S’0

1–

27–

cla

ss2

6.

pp

t

PO

ST

requ

est

PO

ST

/cg

i-

bin

/po

st.p

l HT

TP

/1.1

A

cce

pt:

ima

ge

/gif,

ima

ge

/x-

xbitm

ap

, im

ag

e/jp

eg

, im

ag

e/

pjp

eg

, a

pp

lica

tion

/vn

d.m

s-

exc

el,

ap

plic

atio

n/

msw

ord

, a

pp

lica

tion

/vn

d.m

s-

po

we

rpo

int

, */

* R

efe

rer

: h

ttp

://w

ww

.cs

.cm

u.e

du

/~d

roh

/75

5/f

orm

.htm

l A

cce

pt

-L

an

gu

ag

e:

en

-u

s C

on

ten

t-

Typ

e:

ap

plic

atio

n/x

-w

ww-

form

-u

rle

nco

de

d

Acc

ep

t-

En

cod

ing

: g

zip

, d

efla

te

Use

r-

Ag

en

t:

Mo

zilla

/4.0

(co

mp

atib

le;

MS

IE 4

.01

; W

ind

ow

s 9

8)

Ho

st:

kitt

yha

wk

.cm

cl.

cs.

cmu.

ed

u:8

00

0

Co

nte

nt

-L

en

gth

: 2

5

CR

LF

first

=d

ave

&la

st=

oh

alla

ron

CS

213

S’0

1–

28–

cla

ss2

6.

pp

t

PO

ST

resp

onse

HT

TP

/1.1

20

0 O

KD

ate

: F

ri,

23

Ju

l 19

99

05

:42

:30

GM

TS

erv

er:

Ap

ach

e/1

.3.4

(U

nix

)T

ran

sfe

r-

En

cod

ing

: ch

un

ked

Co

nte

nt

-T

ype

: te

xt/h

tml

CR

LF

<p

>fir

st=

da

ve&

last

=o

ha

llaro

n

Ge

ne

rate

d b

yC

GI

scri

pt

po

st.p

l

Ge

ne

rate

d b

yse

rve

r

CS

213

S’0

1–

29–

cla

ss2

6.

pp

t

TR

AC

E , P

UT,

and

DE

LE

TE

met

hods

T

RA

CE

•R

etur

ns c

onte

nts

of re

ques

t hea

der i

n re

spon

se m

essa

ge b

ody.

•H

TT

P’s

ver

sion

of a

n ec

ho s

erve

r.•

Use

ful f

or d

ebug

ging

.

PU

T:

•ad

d a

UR

I to

the

serv

er’s

file

sys

tem

DE

LET

E•

dele

te a

UR

I fro

m th

e se

rver

’s fi

le s

yste

m

CS

213

S’0

1–

30–

cla

ss2

6.

pp

tSer

ving

dyn

amic

con

tent

clie

ntse

rver

Clie

nt s

ends

requ

est t

o se

rver

.If

requ

est U

RI c

onta

ins

the

strin

g “

/cg

i-

bin

”, th

en

the

serv

er a

ssum

es th

at

the

requ

est i

s fo

r dyn

amic

co

nten

t.

GE

T /

cgi

-b

in/

en

v.p

l HT

TP

/1.1

CS

213

S’0

1–

31–

cla

ss2

6.

pp

tSer

ving

dyn

amic

con

tent

clie

ntse

rver

The

ser

ver c

reat

es a

chi

ld

proc

ess

and

runs

the

prog

ram

iden

tifie

d by

the

UR

I in

that

pro

cess

env.

plfork

/exe

c

CS

213

S’0

1–

32–

cla

ss2

6.

pp

tSer

ving

dyn

amic

con

tent

clie

ntse

rver

The

chi

ld ru

ns a

nd

gene

rate

s th

e dy

nam

ic

cont

ent.

The

ser

ver c

aptu

res

the

cont

ent o

f the

chi

ld a

nd

forw

ards

it w

ithou

t m

odifi

catio

n to

the

clie

nten

v.plco

nten

t

cont

ent

CS

213

S’0

1–

33–

cla

ss2

6.

pp

tSer

ving

dyn

amic

con

tent

clie

ntse

rver

The

chi

ld te

rmin

ates

.S

erve

r wai

ts fo

r the

nex

t cl

ient

requ

est.

CS

213

S’0

1–

34–

cla

ss2

6.

pp

t

Issu

es in

ser

ving

dyn

amic

con

tent

How

doe

s th

e cl

ient

pas

s pr

ogra

m

argu

men

ts to

the

serv

er?

How

doe

s th

e se

rver

pas

s th

ese

argu

men

ts to

the

child

?H

ow d

oes

the

serv

er p

ass

othe

r in

fo re

leva

nt to

the

requ

est t

o th

e ch

ild?

How

doe

s th

e se

rver

cap

ture

the

cont

ent p

rodu

ced

by th

e ch

ild?

The

se is

sues

are

add

ress

ed b

y th

e C

omm

on G

atew

ay In

terf

ace

(CG

I)

spec

ifica

tion.

clie

ntse

rver

cont

ent

cont

ent

requ

est

crea

te

env.

pl

CS

213

S’0

1–

35–

cla

ss2

6.

pp

t

CG

IB

ecau

se th

e ch

ildre

n ar

e w

ritte

n ac

cord

ing

to th

e C

GI

spec

, the

y ar

e of

ten

calle

d C

GI p

rogr

ams.

Bec

ause

man

y C

GI p

rogr

ams

are

writ

ten

in

Per

l, th

ey

are

ofte

n ca

lled

CG

I scr

ipts

.

How

ever

, CG

I rea

lly d

efin

es a

sim

ple

stan

dard

for

tran

sfer

ring

info

rmat

ion

betw

een

the

clie

nt (b

row

ser)

, th

e se

rver

, and

the

child

pro

cess

.

CS

213

S’0

1–

36–

cla

ss2

6.

pp

t

add.

com

: T

HE

Inte

rnet

add

ition

por

tal!

Eve

r nee

d to

add

two

num

bers

toge

ther

and

you

just

ca

n’t f

ind

your

cal

cula

tor?

Try

Dr.

Dav

e’s

addi

tion

serv

ice

at a

dd.c

om: T

HE

In

tern

et a

dditi

on p

orta

l! •

Tak

es a

s in

put t

he tw

o nu

mbe

rs y

ou w

ant t

o ad

d to

geth

er.

•R

etur

ns th

eir s

um in

a ta

stef

ul p

erso

naliz

ed m

essa

ge.

Afte

r the

IPO

we’

ll ex

pand

to m

ultip

licat

ion!

CS

213

S’0

1–

37–

cla

ss2

6.

pp

tThe

add

.com

exp

erie

nce

inpu

t UR

L

Out

put p

age

host

port

CG

I pro

gram

args

CS

213

S’0

1–

38–

cla

ss2

6.

pp

t

Ser

ving

dyn

amic

con

tent

with

GE

T

Que

stio

n:H

ow d

oes

the

clie

nt p

ass

argu

men

ts to

the

serv

er?

Ans

wer

:T

he a

rgum

ents

are

app

ende

d to

the

UR

I

Can

be

enco

ded

dire

ctly

in a

UR

L ty

ped

to a

bro

wse

r or

a U

RL

in a

n H

TM

L lin

k

•h

ttp

://a

dd

.co

m/

cgi

-b

in/a

dd

er?

1&

2

•a

dd

er

is th

e C

GI p

rogr

am o

n th

e se

rver

that

will

do

the

addi

tion.

•ar

gum

ent l

ist s

tart

s w

ith

“?”

•ar

gum

ents

sep

arat

ed b

y “&

•sp

aces

repr

esen

ted

by

“+”

or

“%2

0”

Can

als

o be

gen

erat

ed b

y an

HT

ML

form

<fo

rm m

eth

od

=g

et

act

ion

="h

ttp

://a

dd

.co

m/

cgi

-b

in/

po

sta

dd

er

">

CS

213

S’0

1–

39–

cla

ss2

6.

pp

t

Ser

ving

dyn

amic

con

tent

with

GE

TU

RL:

htt

p:/

/ad

d.c

om

/cg

i-

bin

/ad

de

r?1

&2

Res

ult d

ispl

ayed

on

brow

ser:

Wel

com

e to

add

.com

: TH

E In

tern

et a

dditi

on p

orta

l.

The

ans

wer

is: 1

+ 2

= 3

Tha

nks

for

visi

ting!

Tel

l you

r fr

iend

s.

CS

213

S’0

1–

40–

cla

ss2

6.

pp

t

Ser

ving

dyn

amic

con

tent

with

GE

TQ

uest

ion

: How

doe

s th

e se

rver

pas

s th

ese

argu

men

ts to

the

child

?A

nsw

er:

In e

nviro

nmen

t var

iabl

e Q

UE

RY

_ST

RIN

G•

a si

ngle

str

ing

cont

aini

ng e

very

thin

g af

ter t

he “?

”•

for a

dd.c

om:

QU

ER

Y_

ST

RIN

G= “

1&

2”

/* c

hild

co

de

th

at

acc

ess

es

the

arg

um

en

t lis

t */

if ((

bu

f=

g

ete

nv

("Q

UE

RY

_S

TR

ING

"))

==

NU

LL

) {

exi

t(1

);

} /* e

xtra

ct a

rg1

an

d a

rg2

fro

m

bu

fa

nd

co

nve

rt *

/..

.n

1 =

a

toi

(arg

1);

n2

=

ato

i(a

rg2

);

CS

213

S’0

1–

41–

cla

ss2

6.

pp

t

Ser

ving

dyn

amic

con

tent

with

GE

TQ

uest

ion:

How

doe

s th

e se

rver

pas

s ot

her i

nfo

rele

vant

to

the

requ

est t

o th

e ch

ild?

Ans

wer

:in

a c

olle

ctio

n of

env

ironm

ent v

aria

bles

de

fined

by

the

CG

I spe

c.

CS

213

S’0

1–

42–

cla

ss2

6.

pp

t

Som

e C

GI e

nviro

nmen

t var

iabl

esG

ener

al•

SE

RV

ER

_S

OF

TW

AR

E

•S

ER

VE

R_

NA

ME

•G

AT

EW

AY

_IN

TE

RF

AC

E(CG

I ver

sion

)

Req

uest

-spe

cific

•S

ER

VE

R_

PO

RT

•R

EQ

UE

ST

_M

ET

HO

D( GE

T, P

OS

T, et

c)•

QU

ER

Y_

ST

RIN

G(co

ntai

ns

GE

Tar

gs)

•R

EM

OT

E_

HO

ST(d

omai

n na

me

of c

lient

)•

RE

MO

TE

_A

DD

R(IP

add

ress

of c

lient

)•

CO

NT

EN

T_

TY

PE(f

or P

OS

T, ty

pe o

f dat

a in

mes

sage

bod

y, e

.g.,

text

/htm

l)

•C

ON

TE

NT

_L

EN

GT

H(leng

th in

byt

es)

CS

213

S’0

1–

43–

cla

ss2

6.

pp

t

Som

e C

GI e

nviro

nmen

t var

iabl

esIn

add

ition

, the

val

ue o

f eac

h he

ader

of t

ype

type

rece

ived

from

the

clie

nt is

pla

ced

in e

nviro

nmen

t va

riabl

e H

TT

P_t

ype

•E

xam

ples

:–

HT

TP

_A

CC

EP

T

–H

TT

P_

HO

ST

–H

TT

P_

US

ER

_A

GE

NT(a

ny “

-” is

cha

nged

to “_

”)

CS

213

S’0

1–

44–

cla

ss2

6.

pp

t

Ser

ving

dyn

amic

con

tent

with

GE

TQ

uest

ion:

How

doe

s th

e se

rver

cap

ture

the

cont

ent

prod

uced

by

the

child

?A

nsw

er:

The

chi

ld w

rites

its

head

ers

and

cont

ent t

o st

dout

.•

Ser

ver m

aps

sock

et d

escr

ipto

r to

stdo

ut(m

ore

on th

is la

ter)

.•

Not

ice

that

onl

y th

e ch

ild k

now

s th

e ty

pe a

nd s

ize

of th

e co

nten

t. T

hus

the

child

(not

the

serv

er) m

ust g

ener

ate

the

corr

espo

ndin

g he

ader

s./*

ch

ild g

en

era

tes

the

re

sult

stri

ng

*/

spri

ntf

(co

nte

nt,

"W

elc

om

e t

o a

dd

.co

m:

TH

E I

nte

rne

t a

dd

itio

n p

ort

al

\<

p>

Th

e a

nsw

er

is:

%d

+ %

d =

%d

\<

p>

Th

an

ks f

or

visi

ting

!\

n",

n

1,

n2

, n

1+

n2

);

/* c

hild

ge

ne

rate

s th

e h

ea

de

rs a

nd

dyn

am

ic c

on

ten

t */

pri

ntf

("C

on

ten

t-

len

gth

: %

d\

n",

st

rle

n(c

on

ten

t));

pri

ntf

("C

on

ten

t-

typ

e:

text

/htm

l\

n")

;p

rin

tf("

\r

\n

");

pri

ntf

("%

s",

con

ten

t);

CS

213

S’0

1–

45–

cla

ss2

6.

pp

t

Ser

ving

dyn

amic

con

tent

with

GE

T

ba

ss>

tin

y 8

00

0G

ET

/cg

i-

bin

/ad

de

r?1

&2

HT

TP

/1.1

Ho

st:

ba

ss.

cmcl

.cs

.cm

u.e

du

:80

00

<C

RL

F>

kitt

yha

wk

> t

eln

et

ba

ss 8

00

0T

ryin

g 1

28

.2.2

22

.85

...

Co

nn

ect

ed

to

BA

SS

.CM

CL

.CS

.CM

U.E

DU

.E

sca

pe

ch

ara

cte

r is

'^]'.

GE

T /

cgi

-b

in/a

dd

er?

1&

2 H

TT

P/1

.1H

ost

: b

ass

.cm

cl.

cs.

cmu.

ed

u:8

00

0<

CR

LF

>H

TT

P/1

.1 2

00

OK

Se

rve

r: T

iny

We

b S

erv

er

Co

nte

nt

-le

ng

th:

10

2C

on

ten

t-

typ

e:

text

/htm

l<

CR

LF

>W

elc

om

e t

o a

dd

.co

m:

TH

E I

nte

rne

t a

dd

itio

n p

ort

al.

<p

>T

he

an

swe

r is

: 1

+ 2

= 3

<p

>T

ha

nks

fo

r vi

sitin

g!

Co

nn

ect

ion

clo

sed

by

fore

ign

ho

st.

kitt

yha

wk

>

HT

TP

requ

est r

ecei

ved

byse

rver

HT

TP

requ

est s

ent b

y cl

ient

HT

TP

resp

onse

gen

erat

ed b

yth

e se

rver

HT

TP

resp

onse

gen

erat

ed b

yth

e C

GI p

rogr

am