Web Services Nov 26, 2002 Web Services Nov 26, 2002
Topics Topics
- HTTP
- Serving static content
- Serving dynamic content
15-213 The course that gives CMU its Zip! Web Services Web - - PowerPoint PPT Presentation
15-213 The course that gives CMU its Zip! Web Services Web Services Nov 26, 2002 Nov 26, 2002 Topics Topics HTTP Serving static content Serving dynamic content
– 2 – 15-213, F’02
Describes the idea of a distributed hypertext system. A “memex” that mimics the “web of trails” in our minds.
Connects “a web of notes with links.” Intended to help CERN physicists in large projects share and manage information
– 3 – 15-213, F’02
– 4 – 15-213, F’02
– 5 – 15-213, F’02
Web server
✏✒✑✓✑✓✔ ✕☛✖✓✗✓✘✓✖✒✙✓✚ ✏✒✑✓✑✓✔ ✕☛✖✒✙✝✛✢✜☛✣✒✙☛✖ ✤✦✥ ✜☛✣✒✚☛✖✓✣✒✚✒✧Client and server establish TCP connection
★Client requests content
★Server responds with requested content
★Client and server close connection (usually)
RFC 2616, June, 1999. Web client (browser)
– 6 – 15-213, F’02
– 7 – 15-213, F’02
Examples: HTML files, images, audio clips.
Example: content produced by a program executed by the server on behalf of the client.
– 8 – 15-213, F’02
Identifies a file called
▲ ✣✓▼✓✖✓◆P❖✦◗✒✚✝❘✢❙❯❚ managed by a Web server at ❱✓❱✓❱ ❖ ✥ ✙❲❖ ✥ ❘✒✘❳❖✦✖✓▼✓✘ that is listening on port 80.Identifies an executable file called
❛ ▼✓▼✓✖✒✕ , managed by a Webserver at
❱✓❱✓❱ ❖ ✥ ✙❁❖ ✥ ❘✒✘❜❖✦✖✓▼✓✘ that is listening on port 8000, thatshould be called with two argument strings:
❝✓❞✓❡✓❡✓❡ and ❢✓❝✓❣ .– 9 – 15-213, F’02
No hard and fast rules for this. Convention: executables reside in
✥☛❤ ▲❥✐✄❦✢▲ ✣directory
Initial “
❧ ” in suffix denotes home directory for requestedcontent. Minimal suffix is “
❧ ”, which all servers expand to some defaulthome page (e.g., ▲
✣✓▼✓✖✓◆P❖✦◗✒✚✝❘✢❙ ).– 10 – 15-213, F’02
Client: open connection to server
❶✲❷❉❸ ♦❉♥✴❹ ❺✴❻✴❼✰❽⑦❾✴❿✴❿✰❽⑦❾✴➀✲➁✫❽⑦❺✴➂✰❽r❽✴❽Telnet prints 3 lines to the terminal
➃✴➄ ♥✴♥✴➅✲➆✴➇❉➅r➈ ➇ ➄ ➉✴➄✲➊ ❽⑦➆ ➄❉➋ ❽ ➌✲➍ ➆ ➉❉➎ ➅ ➆❉➏ ➉ ❷ ➉ ➆✴➇❉➅ ❷ ♦ ➍ ➐⑦➑✲➒✫➐ ❽ ➓ ➌✴❶ ➔ →✴❶✴❶✲➣✴➔ ❾✰❽⑦❾Client: request line
➏ ➄ ➍ ➇✰↔ ↕✴↕✴↕✮❽ ➉✴➄✲➊ ❽⑦➆ ➄❉➋Client: required HTTP/1.1 HOST header Client: empty line terminates headers
❽ →✴❶✴❶✲➣✴➔ ❾✰❽⑦❻ ❺✴❻✴❻ ➙✴➛ ➜✫➝❏➜✲➌✲➞❏➟ ➅ ❷✴➍ ♦ ➄ ♥✷↔ ❾✰❽⑦❻Server: followed by five response headers
➠ ➉ ➇❉➅✷↔ ➜ ➄ ♥✷➡ ❻✴❿ ➢ ➉ ♥ ❺✴❻✴❻✴❾ ❻✴➀✰↔⑦❼✲➤✫↔⑦➀✴❺ ➓ ➜❥❶ ➥ ➅ ❷❉➦ ➅ ❷ ↔ ➧ ➉ ➦ ♦ ➥ ➅ ❷❉➦ ➅ ❷➨➔ ❺✰❽⑦❻ ➩✲➙✴➫ ➍ ➅ ❷❉➦ ➅ ❷➨➔ ❺✰❽⑦➂✰❽⑦➂ ➃✴➄ ♥✲➇❉➅✴♥✲➇ ➞❉❶✴❸ ➎ ➅✷↔ ➇❉➅✴♣✲➇ ➔ ➏✲➇ ➋✽➊Server: expect HTML in the response body
➃✴➄ ♥✲➇❉➅✴♥✲➇ ➞ ➫✴➅✴♥✴❹✲➇❉➏✷↔ ➀✴❺✴❻✲➤❉❺Server: expect 42,092 bytes in the resp body Server: empty line (“
➭⑦➯✰➭ ✈ ”) terminates hdrs ➲ ➏✲➇ ➋✫➊ qServer: first HTML line in response body
❽✴❽✴❽Server: 766 lines of HTML not shown.
➲ ➔ ➏✲➇ ➋✫➊ qServer: last HTML line in response body
➃✴➄ ♥✴♥✴➅✲➆✴➇✴♦ ➄ ♥ ➆ ➊❉➄ ➍ ➅✴➈ ➳ ❸ ➵ ➄ ❷ ➅✲♦❉❹✴♥ ➏ ➄ ➍ ➇✰❽Server: closes connection
♠✴♥✲♦❉♣✴qClient: closes connection and terminates
– 11 – 15-213, F’02
– 12 – 15-213, F’02
Arguments for dynamic content are in URI Workhorse method (99% of requests)
Arguments for dynamic content are in the request body
Useful for debugging.
– 13 – 15-213, F’02
multiple transactions over the same connection
Ð ✜☛✣✓✣✓✖ ✥ ✚ ▲ ✜☛✣PÑ Ò✓✖✓✖☛✛ ✐③Ó ❙ ▲☛Ô ✖– 14 – 15-213, F’02
200 OK Request was handled without error 403 Forbidden Server lacks permission to access file 404 Not found Server couldn’t find the file.
– 15 – 15-213, F’02
– 16 – 15-213, F’02
– 17 – 15-213, F’02
Client Server
– 18 – 15-213, F’02
Client Server
– 19 – 15-213, F’02
Client Server
Content Content
– 20 – 15-213, F’02
Client Server Content Content Request Create
✖✓✣ Ô ❖î✛✢❙– 21 – 15-213, F’02
– 22 – 15-213, F’02
– 23 – 15-213, F’02
input URL Output page host port CGI program args
– 24 – 15-213, F’02
– 25 – 15-213, F’02
– 26 – 15-213, F’02
– 27 – 15-213, F’02
– 28 – 15-213, F’02
– 29 – 15-213, F’02
– 30 – 15-213, F’02
Notice that only the child knows the type and size of the content. Thus the child (not the server) must generate the corresponding headers.
➔ Ü ➆❉➏✲♦ ➊ ➈ ❹✴➅✴♥✴➅ ❷ ➉ ➇❉➅ ➍ ➇❉➏✴➅ ❷ ➅ ➍ ♠ ➊ ➇ ➍ ➇ ❷ ♦❉♥✴❹ Ü ➔ ➍ ➎ ❷ ♦❉♥✲➇ ➵ ßÛ➆ ➄ ♥✲➇❉➅✴♥✲➇✰➡ é⑦á✲➅ ➊ ➆ ➄❉➋ ➅ ➇ ➄ ➉ ➈✴➈✷❽⑦➆ ➄❉➋ ↔ ❶✴→✴➌ ➝ ♥✲➇❉➅ ❷ ♥✴➅✲➇ ➉ ➈✴➈✲♦✴➇✴♦ ➄ ♥ ➎✲➄ ❷ ➇ ➉✲➊ æ ➲ ➎ q ❶ ➏✴➅ ➉ ♥ ➍ ↕✲➅ ❷ ♦ ➍ ↔ ✏❉➈ ✑ ✏ ➈ ë ✏❉➈✲æ ➲ ➎ q ❶ ➏ ➉ ♥✓✒ ➍ ➵ ➄ ❷ ➦ ♦ ➍ ♦✴➇✴♦❉♥✴❹✕✔⑦æ ❷ æ❉♥✫é✽➡ ♥✲❾✰➡ ♥✲❺✰➡ ♥✲❾✖✑✴♥✲❺✲â✲à ➔ Ü ➆❉➏✲♦ ➊ ➈ ❹✴➅✴♥✴➅ ❷ ➉ ➇❉➅ ➍ ➇❉➏✴➅ ➏✴➅ ➉ ➈✴➅ ❷✴➍ ➉ ♥✴➈ ➈ ❸ ♥ ➉❉➋ ♦✴➆ ➆ ➄ ♥Ï➇❉➅✴♥✲➇ Ü ➔ ➎ ❷ ♦❉♥✲➇ ➵ ß⑦é ➃✴➄ ♥✲➇❉➅r♥✲➇ ➞ ➊ ➅✴♥✴❹✲➇❉➏✷↔ ✏❉➈✲æ ❷ æ❉♥✫é✫➡ ➍ ➇ ❷ ➊ ➅✴♥✮ßÛ➆ ➄ ♥✲➇Ú➅✴♥✲➇✲â✴â✲à ➎ ❷ ♦❉♥✲➇ ➵ ß⑦é ➃✴➄ ♥✲➇❉➅✴♥✲➇ ➞ ➇ ❸ ➎ ➅✷↔ ➇❉➅✴♣✲➇ ➔ ➏✲➇ ➋✫➊ æ ❷ æ❉♥✫é✴â✲à ➎ ❷ ♦❉♥✲➇ ➵ ß⑦é❉æ ❷ æ❉♥✫é✴â✲à ➎ ❷ ♦❉♥✲➇ ➵ ß⑦é✖✏ ➍ é✫➡ ➆ ➄ ♥✲➇❉➅✴♥✲➇✲â✲à– 31 – 15-213, F’02
HTTP request received by Tiny Web server HTTP request sent by client HTTP response generated by the server HTTP response generated by the CGI program
– 32 – 15-213, F’02
Client Proxy Origin Server
HTTP request HTTP request HTTP response HTTP response
– 33 – 15-213, F’02
Client A Proxy cache Origin Server
Request
➵ ➄✴➄ ❽Û➏✲➇ ➋✫➊Request
➵ ➄✴➄ ❽Û➏✲➇ ➋✫➊ ➵ ➄✴➄ ❽Û➏✲➇ ➋✫➊ ➵ ➄✴➄ ❽Û➏✲➇ ➋✫➊Client B
Request
➵ ➄✴➄ ❽Û➏Ï➇ ➋✫➊ ➵ ➄✴➄ ❽Û➏✲➇ ➋✫➊Fast inexpensive local network Slower more expensive global network
– 34 – 15-213, F’02
text files, HTML files, GIF and JPEG images.