Web Server Design Week 4 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 2/03/10.

Slides:



Advertisements
Similar presentations
HTTP HyperText Transfer Protocol. HTTP Uses TCP as its underlying transport protocol Uses port 80 Stateless protocol (i.e. HTTP Server maintains no information.
Advertisements

1 Caching in HTTP Representation and Management of Data on the Internet.
HTTP – HyperText Transfer Protocol
16-Jun-15 HTTP Hypertext Transfer Protocol. 2 HTTP messages HTTP is the language that web clients and web servers use to talk to each other HTTP is largely.
How the web works: HTTP and CGI explained
The abs_path in a URI If the abs_path is not present in the URL, it must be given as "/" in a Request-URI for a resource. Thus, if a user points a browser.
The abs_path in a URI If the abs_path is not present in the URL, it must be given as "/" in a Request-URI for a resource. Thus, if a user points a browser.
Hypertext Transport Protocol CS Dick Steflik.
Web Server Design Week 5 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 2/10/10.
COMP3016 Web Technologies Introduction and Discussion What is the Web?
Java Technology and Applications
Krerk Piromsopa. Web Caching Krerk Piromsopa. Department of Computer Engineering. Chulalongkorn University.
HTTP Protocol Specification
CSC 2720 Building Web Applications Getting and Setting HTTP Headers (With PHP Examples)
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
TCP/IP Protocol Suite 1 Chapter 22 Upon completion you will be able to: World Wide Web: HTTP Understand the components of a browser and a server Understand.
Maryam Elahi University of Calgary – CPSC 441.  HTTP stands for Hypertext Transfer Protocol.  Used to deliver virtually all files and other data (collectively.
Web Server Design Week 14 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 4/14/10.
Web Server Design Week 1 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 1/13/10.
Web Programming Week 1 Old Dominion University Department of Computer Science CS 418/518 Fall 2010 Martin Klein 8/31/10.
Web Server Design Week 8 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 3/3/10.
HTTP1 Hypertext Transfer Protocol (HTTP) After this lecture, you should be able to:  Know how Web Browsers and Web Servers communicate via HTTP Protocol.
Web Server Design Assignment #1: Basic Operations Due: 02/03/2010 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin.
HTTP support for caching & replication. Conditional requests Server executes conditional request. Responds with a message body only if the condition is.
Web Server Design Week 11 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 3/24/10.
1-1 HTTP request message GET /somedir/page.html HTTP/1.1 Host: User-agent: Mozilla/4.0 Connection: close Accept-language:fr request.
Web Server Design Assignment #2: Conditionals & Persistence Due: 02/24/2010 Old Dominion University Department of Computer Science CS 495/595 Spring 2010.
Appendix E: Overview of HTTP ©SoftMoore ConsultingSlide 1.
Web Server Design Week 2 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 1/20/10.
Web Server Design Week 7 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 2/24/10.
Web Server Design Week 13 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 4/7/10.
HTTP Here, we examine the hypertext transfer protocol (http) – originally introduced around 1990 but not standardized until 1997 (version 1.0) – protocol.
Web Server Design Week 6 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 2/17/10.
Web Server Design Week 10 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 3/17/10.
Web Server Design Week 5 Old Dominion University Department of Computer Science CS 495/595 Spring 2012 Michael L. Nelson 02/07/12.
Web Programming Week 1 Old Dominion University Department of Computer Science CS 418/518 Fall 2007 Michael L. Nelson 8/27/07.
Web Server Design Week 1 Old Dominion University Department of Computer Science CS 495/595 Spring 2006 Michael L. Nelson 1/09/06.
Web Server Design Week 13 Old Dominion University Department of Computer Science CS 495/595 Spring 2012 Michael L. Nelson 04/03/12.
Web Server Design Week 15 Old Dominion University Department of Computer Science CS 495/595 Spring 2009 Michael L. Nelson 4/20/09.
Web Server Design Week 3 Old Dominion University Department of Computer Science CS 495/595 Spring 2006 Michael L. Nelson 1/23/06.
Web Server Design Week 6 Old Dominion University Department of Computer Science CS 495/595 Spring 2006 Michael L. Nelson 2/13/06.
Web Server Design Week 10 Old Dominion University
Web Server Design Week 4 Old Dominion University
Hypertext Transfer Protocol
Web Server Design Assignment #2: Conditionals & Persistence
Web Server Design Week 8 Old Dominion University
Web Server Design Week 11 Old Dominion University
Web Server Design Week 7 Old Dominion University
Web Server Design Week 4 Old Dominion University
Web Server Design Week 15 Old Dominion University
Web Server Design Week 5 Old Dominion University
Web Server Design Assignment #2: Conditionals & Persistence
Web Server Design Week 8 Old Dominion University
Web Server Design Week 8 Old Dominion University
Web Server Design Week 6 Old Dominion University
Web Server Design Week 10 Old Dominion University
Web Server Design Week 8 Old Dominion University
Web Server Design Week 3 Old Dominion University
Web Server Design Week 11 Old Dominion University
Web Server Design Week 5 Old Dominion University
Web Server Design Week 3 Old Dominion University
Web Server Design Week 4 Old Dominion University
Web Server Design Week 14 Old Dominion University
Web Server Design Week 6 Old Dominion University
Web Server Design Assignment #5 Extra Credit
Web Server Design Week 3 Old Dominion University
Web Server Design Week 3 Old Dominion University
Web Server Design Week 7 Old Dominion University
Web Programming Week 1 Old Dominion University
Web Server Design Week 7 Old Dominion University
Presentation transcript:

Web Server Design Week 4 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 2/03/10

Status 301 Moved Permanently Main use: redirect requests for directories not ending in a “/” Can be configured for other resources Browsers typically handle 301 (and 302, 303 & 307) transparently mk$ telnet 80 Trying Connected to xenon.cs.odu.edu. Escape character is '^]'. GET /~mklein/teaching/cs595-s10/a1-test/2 HTTP/1.1 connection: close host: HTTP/ Moved Permanently Date: Tue, 02 Feb :56:32 GMT Server: Apache/ (Unix) DAV/2 PHP/ Location: Content-Length: 362 Connection: close Content-Type: text/html; charset=iso Moved Permanently Moved Permanently The document has moved here. Apache/ (Unix) DAV/2 PHP/ Server at Port 80 Connection closed by foreign host.

When is it not Permanent? % cd $WWW_home % mkdir foo % touch foo/bar % lynx [returns a directory listing] … % rm -rf foo % echo “this is not a directory” > foo % lynx [returns a file] Moved Permanently The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs.

Status 302 Found Found The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field. The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s). If the 302 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued. Note: RFC 1945 and RFC 2068 specify that the client is not allowed to change the method on the redirected request. However, most existing user agent implementations treat 302 as if it were a 303 response, performing a GET on the Location field-value regardless of the original request method. The status codes 303 and 307 have been added for servers that wish to make unambiguously clear which kind of reaction is expected of the client. % telnet 80 Trying Connected to Escape character is '^]'. GET / HTTP/1.1 Host: HTTP/ Found Date: Sun, 04 Feb :29:13 GMT Server: Apache Set-Cookie: PHPSESSID=1ea69c374ee8ee5c8df78e8c4105cc3e; expires=Sun, 18 Feb :29:18 GMT; path=/; domain=techsideline.com Expires: Thu, 19 Nov :52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Location: /home Connection: close Transfer-Encoding: chunked Content-Type: text/html 0 Connection closed by foreign host.

303 See Other The response to the request can be found under a different URI and SHOULD be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. The new URI is not a substitute reference for the originally requested resource. The 303 response MUST NOT be cached, but the response to the second (redirected) request might be cacheable. The different URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s). Note: Many pre-HTTP/1.1 user agents do not understand the 303 status. When interoperability with such clients is a concern, the 302 status code may be used instead, since most user agents react to a 302 response as described here for 303.

Cool URIs For The Semantic Web 303 Redirection has been retroactively claimed for supporting using http URIs for identifying “real world objects” (not just web pages about real world objects) –see:

307 Temporary Redirect The requested resource resides temporarily under a different URI. Since the redirection MAY be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field. The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s), since many pre-HTTP/1.1 user agents do not understand the 307 status. Therefore, the note SHOULD contain the information necessary for a user to repeat the original request on the new URI. If the 307 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

Pseudo-HTTP Redirection % telnet list.odu.edu 80 Trying Connected to list.odu.edu. Escape character is '^]'. GET / HTTP/1.1 Host: list.odu.edu HTTP/ OK Date: Sun, 04 Feb :28:07 GMT Server: Apache Last-Modified: Tue, 02 Aug :21:52 GMT ETag: "3d3c9-17d-3b2fbc00" Accept-Ranges: bytes Content-Length: 381 Content-Type: text/html; charset=ISO Redirect to web.odu.edu... Redirect to Connection closed by foreign host.

A Simple Request… Trying Connected to xenon.cs.odu.edu. Escape character is '^]'. HTTP/ OK Date: Sun, 05 Feb :58:27 GMT Server: Apache/ (Unix) ApacheJServ/1.1.2 PHP/4.3.4 Last-Modified: Sun, 29 Jan :43:15 GMT ETag: "1f4de dd0cc3" Accept-Ranges: bytes Content-Length: 1936 Connection: close Content-Type: text/html Michael Nelson's 1966 Ford Fairlane […] If the resource is large, we might not want to grab the whole thing frequently unless it has changed We could combine HEAD & GET, or we can modify our request with additional headers

Status 304 Not Modified AIHT.local:/Users/mln/Desktop/cs595-s06 % telnet 80 | tee 5-2.out Trying Connected to xenon.cs.odu.edu. Escape character is '^]'. GET /~mln/teaching/cs595-s06/a1-test/2/index.html HTTP/1.1 Host: Connection: close If-Modified-Since: Sun, 29 Jan :43:15 GMT HTTP/ Not Modified Date: Sun, 05 Feb :58:41 GMT Server: Apache/ (Unix) ApacheJServ/1.1.2 PHP/4.3.4 Connection: close ETag: "1f4de dd0cc3" AIHT.local:/Users/mln/Desktop/cs595-s06 % telnet 80 | tee 5-3.out Trying Connected to xenon.cs.odu.edu. Escape character is '^]'. GET /~mln/teaching/cs595-s06/a1-test/2/index.html HTTP/1.1 Host: Connection: close If-Modified-Since: Sun, 29 Jan :43:14 GMT HTTP/ OK Date: Sun, 05 Feb :58:52 GMT Server: Apache/ (Unix) ApacheJServ/1.1.2 PHP/4.3.4 Last-Modified: Sun, 29 Jan :43:15 GMT ETag: "1f4de dd0cc3" Accept-Ranges: bytes Content-Length: 1936 Connection: close Content-Type: text/html Michael Nelson's 1966 Ford Fairlane section , 14.25, RFC 2616

Status 412 Precondition Failed AIHT.local:/Users/mln/Desktop/cs595-s06 % telnet 80 | tee 5-5.out Trying Connected to xenon.cs.odu.edu. Escape character is '^]'. GET /~mln/teaching/cs595-s06/a1-test/2/index.html HTTP/1.1 Host: Connection: close If-Unmodified-Since: Sun, 29 Jan :43:15 GMT Connection closed by foreign host. HTTP/ OK Date: Sun, 05 Feb :01:54 GMT Server: Apache/ (Unix) ApacheJServ/1.1.2 PHP/4.3.4 Last-Modified: Sun, 29 Jan :43:15 GMT ETag: "1f4de dd0cc3" Accept-Ranges: bytes Content-Length: 1936 Connection: close Content-Type: text/html Michael Nelson's 1966 Ford Fairlane AIHT.local:/Users/mln/Desktop/cs595-s06 % telnet 80 | tee 5-7.out Trying Connected to xenon.cs.odu.edu. Escape character is '^]'. GET /~mln/teaching/cs595-s06/a1-test/2/index.html HTTP/1.1 Host: Connection: close If-Unmodified-Since: Sun, 29 Jan :43:14 GMT HTTP/ Precondition Failed Date: Sun, 05 Feb :02:22 GMT Server: Apache/ (Unix) ApacheJServ/1.1.2 PHP/4.3.4 Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso Precondition Failed Precondition Failed The precondition on the request for the URL /~mln/teaching/cs595-s06/a1-test/2/index.html evaluated to false. Apache/ Server at Port 80 0 sections , 14.28, RFC 2616

Entity Tags as Conditionals AIHT.local:/Users/mln/Desktop/cs595-s06 % telnet 80 | tee 5-8.out Trying Connected to xenon.cs.odu.edu. Escape character is '^]'. GET /~mln/teaching/cs595-s06/a1-test/2/index.html HTTP/1.1 Host: Connection: close If-Match: "1f4de dd0cc3" HTTP/ OK Date: Sun, 05 Feb :07:12 GMT Server: Apache/ (Unix) ApacheJServ/1.1.2 PHP/4.3.4 Last-Modified: Sun, 29 Jan :43:15 GMT ETag: "1f4de dd0cc3" Accept-Ranges: bytes Content-Length: 1936 Connection: close Content-Type: text/html Michael Nelson's 1966 Ford Fairlane … AIHT.local:/Users/mln/Desktop/cs595-s06 % telnet 80 | tee 5-9.out Trying Connected to xenon.cs.odu.edu. Escape character is '^]'. GET /~mln/teaching/cs595-s06/a1-test/2/index.html HTTP/1.1 Host: Connection: close If-Match: "1f4de dd0cc2" HTTP/ Precondition Failed Date: Sun, 05 Feb :07:21 GMT Server: Apache/ (Unix) ApacheJServ/1.1.2 PHP/4.3.4 Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso Precondition Failed Precondition Failed The precondition on the request for the URL /~mln/teaching/cs595-s06/a1-test/2/index.html evaluated to false. Apache/ Server at Port 80 0 section 14.24, RFC 2616

Getting Fancy With Etags… AIHT.local:/Users/mln/Desktop/cs595-s06 % telnet 80 | tee 5-11.out Trying Connected to xenon.cs.odu.edu. Escape character is '^]'. GET /~mln/teaching/cs595-s06/a1-test/2/index.html HTTP/1.1 Host: Connection: close If-None-Match: "1f4de dd0caa" HTTP/ OK Date: Sun, 05 Feb :10:00 GMT Server: Apache/ (Unix) ApacheJServ/1.1.2 PHP/4.3.4 Last-Modified: Sun, 29 Jan :43:15 GMT ETag: "1f4de dd0cc3" Accept-Ranges: bytes Content-Length: 1936 Connection: close Content-Type: text/html Michael Nelson's 1966 Ford Fairlane AIHT.local:/Users/mln/Desktop/cs595-s06 % telnet 80 | tee 5-12.out Trying Connected to xenon.cs.odu.edu. Escape character is '^]'. GET /~mln/teaching/cs595-s06/a1-test/2/index.html HTTP/1.1 Host: Connection: close If-None-Match: "1f4de dd0caa”, "1f4de dd0cc3" HTTP/ Not Modified Date: Sun, 05 Feb :10:13 GMT Server: Apache/ (Unix) ApacheJServ/1.1.2 PHP/4.3.4 Connection: close ETag: "1f4de dd0cc3" Connection closed by foreign host. section 14.26, RFC if method != GET, HEAD Server will respond if (one) Etag matches and If-Modified-Since header triggers

Combining Conditionals not true true AIHT.local:/Users/mln/Desktop/cs595-s06 % telnet 80 | tee 5-14.out Trying Connected to xenon.cs.odu.edu. Escape character is '^]'. GET /~mln/teaching/cs595-s06/a1-test/2/index.html HTTP/1.1 Host: Connection: close If-Modified-Since: Sun, 29 Jan :43:15 GMT If-Match: "1f4de dd0cc3" HTTP/ Not Modified Date: Sun, 05 Feb :02:18 GMT Server: Apache/ (Unix) ApacheJServ/1.1.2 PHP/4.3.4 Connection: close ETag: "1f4de dd0cc3" Connection closed by foreign host.

Combining Conditionals If-Modified-SinceIf-Unmodified- Since If-MatchIf-None-Match If-Modified-Since--- If-Unmodified- Since undefined--- If-MatchundefinedX--- If-None-MatchXundefined --- If the request normally (i.e., without the *** header) would result in anything other than a 2xx or 412 status, the **** header SHOULD be ignored. X =