Docsity

Serving Dynamic Content, HTTP - Lecture Notes | AMSC 662, Study notes of Mathematics

Partial preview of the text

Download Serving Dynamic Content, HTTP - Lecture Notes | AMSC 662 and more Study notes Mathematics in PDF only on Docsity!

Web Services

Nov 26, 2002

Web Services

Nov 26, 2002

Topics Topics HTTP Serving static content Serving dynamic content

15-

“The course that gives CMU its Zip!”

Web History Web History

1945: 1945:

**Vannevar Bush, “As we may think”, Atlantic Monthly, July,

Describes the idea of a distributed hypertext system. A “memex” that mimics the “web of trails” in our minds.**

1989: 1989:

Tim Berners-Lee (CERN) writes internal proposal to develop a distributed hypertext system. Connects “a web of notes with links.”

Intended to help CERN physicists in large projects share and manage information

1990: 1990:

Tim BL writes a graphical browser for Next machines.

Internet Hosts Internet Hosts

Web Servers Web Servers

Web server

Clients and serversClients and servers

communicate using the communicate using the HyperText HyperText (^) TransferTransfer Protocol (HTTP) Protocol (HTTP)

Client and server establish TCP connection

Client requests content

Server responds with requested content

Client and server close connection (usually)

Current version is HTTP/1.1Current version is HTTP/1.

RFC 2616, June, 1999.

Web client (browser)

Static and Dynamic Content Static and Dynamic Content

The content returned in HTTP responses ca The content returned in HTTP responses can be eithern be either

staticstatic^ oror^ dynamicdynamic .. Static content: content stored in files and retrieved in response to an HTTP request Examples: HTML files, images, audio clips. Dynamic content: content produced on-the-fly in response to an HTTP request

Example: content produced by a program executed by the server on behalf of the client.

Bottom line: Bottom line: All Web content is associated with aAll Web content is associated with a filefile

that is managed by the server.that is managed by the server.

URLs URLs

Each file managed by a se Each file managed by a server has a unique name callrver has a unique name called aed a

URL (Universal Resource Locator) URL (Universal Resource Locator)

URLs for static content: URLs for static content: ,)$+$-1 @/A-B+B+B CD629ECD6-.2F CD%+G&F @/H+I+*&4&52G+%&' CJ,)$/.)

,)$+$-1 @K+-B+B+B CD629ECD6-.2F CD%+G&F)*&4&52G+%&' CJ,)$/.)

,)$+$-1 @/+-B+B+B CD629ECD6-.2F CD%+G&F

Identifies a file called L

MNPO!QRSUT

managed by a Web server at VVV O WO^ RXO!M^ that is listening on port 80.

URLs for dynamic content: URLs for dynamic content: ,)$+$-1 @/+-B+B+B CD629ECD6-.2F CD%+G&F @/H+I+I+I+&6+=+42Y/Z)4&5)&3+G+G+%+:2[+&]2I+I+I+^&_2&`

Identifies an executable file called a

M

M

, managed by a Web server at

V

VV O <O^ RbO!M^ that is listening on port 8000, that should be called with two argument strings: cdeee and fcg.

Anatomy of an HTTP Transaction Anatomy of an HTTP Transaction

m/n-oDprq sDt/uDv-t-s w/w/w+xzy/{/u|x~}/{J €/ (^) Client: open connection to server ‚-ƒD„ (^) oDn/ †/‡/ˆ+‰~Š/‹/‹+‰~Š/Œ-&‰~†/Ž+‰r‰/‰ Telnet prints 3 lines to the terminal / (^) n/n/‘-’/“D‘r” “  •/-– (^) ‰~’ D— (^) ‰ ˜-™ (^) ’ •Dš (^) ‘ ’D› • ƒ • ’/“D‘ ƒ o ™ œ~-ž&œ (^) ‰ Ÿ ˜/‚ ¡/‚/‚-¢/ (^) Š+‰~Š Client: request line ›  ™ “+£ ¤/¤/¤)‰ •/-–^ ‰~’ D—^ Client: required HTTP/1.1 HOST header

Client: empty line terminates headers ‰ ¡/‚/‚-¢/ (^) Š+‰~‡ †/‡/‡ ¥/¦

§&¨J§-˜-©Jª (^) ‘ ƒ/™ (^) o  n2£ Š+‰~‡ Server: followed by five response headers « • “D‘2£ §  n2¬ ‡/‹ • n †/‡/‡/Š ‡/Œ+£~ˆ-®&£~Œ/† Ÿ §j‚ ¯ ‘ ƒD° (^) ‘ ƒ £ ± • ° o ¯ ‘ ƒD° (^) ‘ ƒ² (^) †+‰~‡ ³-¥/´ ™ ‘ ƒD° (^) ‘ ƒ² (^) †+‰~Ž+‰~Ž / (^) n-“D‘/n-“ ©D‚/„ š ‘2£ “D‘/p-“ ›-“ —8– Server: expect HTML in the response body / (^) n-“D‘/n-“ © ´/‘/n/ -“D›2£ Œ/†/‡-®D† Server: expect 42,092 bytes in the resp body Server: empty line (“ μ~¶+μ v ”) terminates hdrs · ›-“ —&–^ q Server: first HTML line in response body ‰/‰/‰ (^) Server: 766 lines of HTML not shown. · ›-“ —&–^ q Server: last HTML line in response body / (^) n/n/‘-’/“/o  n ’ –D ™ ‘/” ¸ „ ¹  ƒ ‘-oD /n ›  ™ “+‰ Server: closes connection m/n-oDp/q (^) Client: closes connection and terminates

HTTP Requests HTTP Requests

HTTP request is a HTTP request is a request linerequest line , followed by zero or, followed by zero or

more more request headersrequest headers

Request line: Request line:

º2»2%+:¼9&4+7&5¼½ is HTTP version of request ( ¾ 2¿+¿+À

|\EC/I

or ¾Á¿+¿+À

+\EC/\

) º2F2:|4+½ is typically URL for proxies, URL suffix for servers. º+.)%¼$-,27|G+½ is either Â8Ã2¿ Ä À&żÆ+¿ Ä Å2À|¿2Ç-Å+È¼Æ Ä ¾+Ã&É¼Ê Ä À&Ë2¿ Ä Ê+Ã2Ì&ü¿&Ã Ä or ¿8Í&É)Î8Ã

C

HTTP Requests (cont) HTTP Requests (cont)

Request headers: Request headers: >>

Provide additional information to the server.

Major differences between HTTP/1.1 a Major differences between HTTP/1.1 and HTTP/1.0nd HTTP/1.

HTTP/1.0 uses a new connection for each transaction. HTTP/1.1 also supports persistent connections multiple transactions over the same connection Ð    L

 PÑ Ò 

i zÓ

S

L Ô

HTTP/1.1 requires ¾+żÆ+¿ header WÑ Õ L

 ÖQ

a

(^) V Õ×O R SØO <O RbO!M

HTTP/1.1 adds additional support for caching

HTTP Responses HTTP Responses

HTTP response is a HTTP response is a response lineresponse line followed by zero orfollowed by zero or

moremore^ response headersresponse headers ..

Response line: Response line:

is HTTP version of the response. is numeric status. is corresponding English text. 200 OK Request was handled without error 403 Forbidden Server lacks permission to access file 404 Not found Server couldn’t find the file.

Response headers: Response headers: Provide additional information about response Î

7 85)$&%85)$+Y

&Ù

MIME type of content in response body. Î

7 85)$&%&5)$|Y

Ì

Length of content in response body.

Response From Apache Server Response From Apache Server

¡/‚/‚-¢r (^) Š+‰~Š †/‡/‡ ¥/¦

« • “D‘2£ ‚ ›/m¼¬ †/† Dm – Š-®/®/® ‡/Œ+£~‡/†+£~Š/ˆ Ÿ §j‚

¯ ‘ ƒD° (^) ‘ ƒ £ ³ š-• (^) ’D›/‘ Š+‰~Ž+‰~Ž ç/‘/n © ¯/¯ (^) ´ Š+‰~†/‹ ßÞ n-oDp&â ´ • ™ “ ©J§^  ”-o ¹ oD‘/”2£ ‚ ›/m2¬ †/† Dm – Š-®/®/® ‡/Žè£~Ž/Ž+£~†/Š Ÿ §-‚ ˜/‚ • 2£ éڌ/‹J¸/¸&† © Œ ¹/© (^) Ž/ê-®//®DŠ/‡/Š-é

³&’/’D‘ š “ © ä/•^ n/ /‘ ™ £ ¸ „ “D‘ ™ / (^) n-“D‘rn-“ © ´/‘/n/ -“D›2£ ê-®

¦/‘/‘ š © ³ – o ° ‘2£ “/o — ‘  m-“Dë-Š/ˆ+¬ —-•^ p/ë-Š/‡/‡ / (^) n/n/‘-’r“/o  n2£ ¦/‘/‘ š © ³ – o ° ‘

/ (^) n-“D‘/nϓ ©D‚/„ š ‘2£ “D‘/p-“ ›-“ —&–

rä (^) ´/å

· ›Ï“ —&–^ q

· ›/‘ • ”/q · “/or“ – ‘/q ‚ ‘ ™ “ š-• (^) /‘ · “/o/“ – ‘/q · ›/‘ • ”/q

· ¸  ” „ q

· ›-ŠDq ‚ ‘ ™ “ š-•^ /‘ · ›-ŠDq

· ›-“ —&–^ q

Serving Dynamic Content Serving Dynamic Content

Client Server

Client sends request to Client sends request to

server. server.

If request URI contains the If request URI contains the

string “ string “ ”, then”, then

the server assumes that the server assumes that

the request is for the request is for

dynamic content. dynamic content.

ìí  l

h L (ikL

l

Ô

OîS  l c

O

c

Serving Dynamic Content (cont) Serving Dynamic Content (cont)

The child runs andThe child runs and Client Server

generates the dynamic generates the dynamic

content. content.

The server captures the The server captures the

content of the child and content of the child and

forwards it without forwards it without

modification to the client modification to the client

Ô

OîS

Content

Content

Issues in Serving Dynamic Content Issues in Serving Dynamic Content

How does the client pass program How does the client pass program

arguments to the server? arguments to the server?

How does the server pass these How does the server pass these

arguments to the child? arguments to the child?

How does the server pass other How does the server pass other

info relevant to the request to info relevant to the request to the child? the child?

How does the server capture the How does the server capture the

content produced by the child? content produced by the child?

These issues are addresse These issues are addressed by thed by the

Common Gateway Interface (CGI) Common Gateway Interface (CGI) specification. specification.

Client Server

Content

Content

Request

Create

Ô

OîS