1 / 37

CMPT 371

CMPT 371. Data Communications and Networking HTTP. HTTP request messages. HTTP request messages are sent by the agent to request that the server provide an object. Each request message includes a method (a command to indicate what is requested) GET most common, gets an object

roy
Download Presentation

CMPT 371

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CMPT 371 Data Communications and Networking HTTP

  2. HTTP request messages • HTTP request messages are sent by the agent to request that the server provide an object. Each request message includes a method (a command to indicate what is requested) • GET most common, gets an object • POST to send user (client) input information • HEAD (like GET, but no object in response) • Others in HTTP v1.1, e.g. PUT, DELETE

  3. HTTP request messages • GET the most commonly used method • request objects from a web server (expecting object to be returned) • POST • may send data entered into an online form to the webserver • For example if the data being sent was variables name and password the POST request would use a url with the form: www.somewhere.com/login?name&password

  4. HTTP request messages • HEAD (similar to GET) • response does not include requested object (primarily for debug) • Others available only in HTTP v1.1 (LATER) • PUT • uploads file in entity body to path specified in URL field • DELETE • deletes file specified in the URL field

  5. HTTP request message Request line: method URL version Header lines: header field name: (any number of lines permitted) Blank line \r\n at start of line indicates the end of the header lines Entity body GET /templates/themes/clf/sfu/scripts/flyout.js HTTP/1.1\r\n Host: www.cs.sfu.ca\r\n User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0 Accept-Language: en-us,en;q=0.5\r\n Keep-Alive: 300\r\n Connection: keep-alive\r\n Referer: http://www.cs.sfu.ca/\r\n \r\n

  6. Request message format • A request line indicating • Method, URL, HTTP version • A header section including details of the request. Each line in the header section includes • A field name • A value for that field • A blank line follow

  7. Request message format The entity body for a GET request message is empty so the CRLF indicating the blank line is the last thing in the request message Request messages for other methods may include an entity body. For example a POST request message

  8. HTTP response messages • HTTP response messages: sent by the server to provide information and or to send objects back to the agent. • Each response begins with a status line containing the HTTP version a status and a phrase • Header with format the same as header for request • A blank line • Returned object is in the entity body

  9. HTTP response messages • Each response begins with a status line: with the HTTP version a status and a phrase • The status is a number • The phrase is a name for the status in english • Each status is associated with one phrase (list in RFC) • OK if everything worked as expected • CREATED, ACCEPTED, MOVED, NOT FOUND, NOT IMPLEMENTED, … (more in your text, see RFCs for complete list)

  10. What if there is a problem? • Status code appears in 1st line in response message. Example codes: • 200 OK • 301 Moved Permanently (location given later in msg) • 400 Bad Request (request not understood by server) • 404 Not Found (requested doc not found on server) • 505 HTTP Version Not Supported

  11. HTTP response message Status line: version status code phrase Header lines: header field name: value CRLF Blank line (carriage return and line feed Entity body: actual object being returned HTTP/1.1 200 OK\r\n Date: Thu, 13 Sep 2007 13:54:26 GMT\r\n Server: Apache/2.0.59 (Unix) mod_fastcgi/2.4.2 SVN/1.4.4 DAV/2 mod_ssl/2.0.59 OpenSSL/0.9.8 PHP/4.4.7\r\n Keep-Alive: timeout=15, max=100\r\n Connection: Keep-Alive\r\n Content-Length: 452\r\n Content-Type: text/html; charset=ISO-8859-1\r\n \r\n Line-based text data: text/html

  12. Cookies • Used by web-sites to identify users and keep track of information about users • Need 4 components to use cookies • A cookie file kept on the users machine managed by the users browser • A data-base of information kept at the website • Information passed between the two above using both the a cookie header line in the HTTP request message and a second cookie header line in the HTTP reply message

  13. Example using cookies (text) • Susan uses her PC to access the internet • She visits an e-shopping site for the 1st time • Her interaction with the site includes sending HTTP requests to the site create • A unique ID stored in a cookie on her computer • An entry in the e-shopping sites database for her account

  14. Using Cookies: save state Myshop2234 HTTP request Myshop server Creates ID 124 Places in DB Created Cookie file HTTP response Set-cookie: 124 Myshop2234 ID 124 database CLIENT (susan) SERVER

  15. Using Cookies: later Myshop2234 ID 124 HTTP request Cookie: 124 Cookie specific actions Access information Created Cookie file HTTP response Later can be immediately after creating cookie, or some time later database CLIENT (susan) SERVER

  16. Caching All objects used to display a requested web page may be stored in a cache When your request the same page or a another page containing some of the same objects, the objects you already have in the cache may not need to be downloaded again, they can simply be loaded from the cache

  17. Proxy web cache A proxy server is a host that provides a service to users. One such service may be a web cache To the client sending the HTTP request the Proxy server appears to be the web server To the web server the Proxy server appears to be the web client Proxy servers are most commonly used by ISPs, institutions (e.g. university, government) or companies

  18. HTTP request using a web cache The local agent (browser) on the users host connects to the proxy server using TCP then makes an HTTP request (for a particular object) to the proxy server The proxy server’s web cache application checks the web cache to see if the requested object is in the cache If the requested object is in the cache, the web cache application will send the object from the cache to the local agent in an HTTP reply. This reduces response time and traffic on external access link (to server)

  19. HTTP request using a web cache If the requested object is not in the cache the web cache will make a TCP connection to the web server, send a HTTP Get requesting the object, and receive an HTTP reply containing the object from the web server. The object returned in the HTTP response from the web server, will be placed in an HTTP reply to the client and then sent to the HTTP client The object returned in the HTTP response will also be placed in the web cache

  20. Server Client 1 (1) Client 1 makes HTTP request (3) Proxy server makes HTTP request (6) Proxy Server sends HTTP reply (4) Server sends HTTP reply (7) Client 2 makes HTTP request Proxy Server (9) Proxy Server sends HTTP reply (2) Proxy checks cache, item in HTTP request is not present (5) Add HTTP reply Client 2 (8) Get cached HTTP reply Proxy Server Cache

  21. Why does caching help Local network 10Mbps Web servers Connection to Internet 1.5Mbps clients Host with network web cache Reduces load on the Internet, fewer copies of the same object are requested Improved security Reducing bottlenecks in bandwidth

  22. Caching example (from text) Average object size, 100k bits Average request rate from institution net 15 / sec Utilization of institutional network 15 * 100K / 10 Mbps = 15% Utilization internet connection for requests (no cache) 15 * 100K /1.5 Mbps = 100% very high utilization implies major delays (minutes)

  23. Caching solution 1 (from text) Average object size, 100k bits Average request rate from institution net 15 / sec Upgrade speed of internet link (expensive) Utilization of institutional network 15 * 100K / 1O Mbps = 15% Utilization internet connection for requests (no cache) 15 * 100K /10 Mbps = 15% modest utilization implies minor delays (msecs)

  24. Caching solution 2 (from text) Average object size, 100k bits Average request rate from institution net 15 / sec Install a cache on the local network. Assume 40% of requests are satisfied by the cache Utilization of institutional network 15 * 100K / 1O Mbps = 15% Utilization internet connection for requests (with cache) (1-0.4) * 15 * 100K /1.5 Mbps = 60% significant utilization implies small delays (10s msecs)

  25. Caching • Caching can increase efficiency • However, one must also assure that the objects in the cache are current. • If an object has changed since it was downloaded, then it should be downloaded again before being displayed as part of the web page • Don’t want to display material that is out of date

  26. Keeping the cache current (1) • How do we assure that the objects displayed on our webpage are up to date • If the object is cached there is a possibility it has changed since it was downloaded • Before we display the object our cache sends a conditional HTTP get message to the server. • Have the server send back the cached information again only it has changed.

  27. Keeping the cache current (2) • To make a Get message conditional the header section must include a If-Modified-Since: header line If-Modified-Since: Wed, 2 May 2003 10:26:11 • The date in the header line is the Last-Modified time that was returned in the HTTP response that originally downloaded the object (the date is saved with the object)

  28. Keeping the cache current (3) • When the request is processed the web server will compare its Last-Modified date of its local copy of the object with the If-Modified-Since date in the request packet • If the object has not been modified since it was last downloaded the server will return a response that includes a status of Not Modified, and does not include the object in the entity body • If the object has been modified the modified object will be returned and replace the old copy in the cache, and be displayed as part of the webpage

  29. CMPT 371 Data Communications and Networking FTTP

  30. FTP • File Transfer Protocol • An application layer communication protocol used to transfer files from one host to another • Often used for downloading files on the Internet • We can use FTP without connecting through the WWW (uses port 21) • For detailed information about HTTP see RFC 959

  31. File transfer protocol • When we want to copy a file from a remote site we can use FTP • When an FTP request is made first a TCP connection is made just to exchange control information. This is called the control connection • A second TCP connection will later be made to do the actual transfer of the requested file. This is called the data connection

  32. Control information • permissions and passwords indicating that the user attempting the download is permitted to access the file requested for download. • Negotiation of the properties (like port) of the data connection • Keep track of the state of the user, for example where in the remote directory tree he is, so the file to transfer can be identified

  33. Common Channel Signaling • Signals travel independently from data, over a separate common channel • The separate channel handles control messages for a number of connections simultaneously. • For FTP each file transfers on a separate channel, all transfers are managed using a single channel • This makes the signaling protocol and the network architecture more complicated

  34. Steps: using FTP (1) Client contacts server (port 21) Client logs in (to control channel), provides password to verify that he /she has access to the available files Client browses files and chooses desired file or files (using LIST, CWD, LS, CD) Client requests first desired file (using RETR in Windows or GET in linux/unix)

  35. Steps: using FTP (2) Server receives transfer command, opens a 2nd TCP connection and transfers the file though the 2nd TCP connection (port 20) When the file has completed transfer the 2nd TCP connection is closed. Server opens another connection to transfer next requested file.

  36. Examples of FTP Commands • sample commands used in the control channel • USER username • PASS password • LIST return list of file in current directory • RETR filename retrieves (gets) file • STOR filename stores (puts) file onto remote host

  37. Examples of FTP replies 331 Username OK, password required 425 Can’t open data connection 452 Error writing file 125 data connection already open; transfer starting

More Related