COMP 2322 Lab 2 HTTP Steven Lee Jan
COMP 2322 Lab 2 HTTP Steven Lee Jan. 29, 2016
HTTP • Hypertext Transfer Protocol • Web’s application layer protocol • Client/server model – Client (browser): requests, receives and displays Web objects, can be HTML files, images, videos, … – Server (Web server): responds requests with objects • Stateless – Server maintains no information about past client requests 2
HTTP message • Two types: request, response • HTTP request message – ASCII (human-readable format) Request line GET /hypertext/WWW/The. Project. html HTTP/1. 1 Host: info. cern. ch User-agent: Mozilla/5. 0 Header lines Connection: keep-alive Accept-language: en-US End of message (extra carriage return r, line feed n) 3
HTTP methods • GET (HTTP/1. 0+) • POST (HTTP/1. 0+) • HEAD (HTTP/1. 0+) – Requests the header only, without the response body • PUT (HTTP/1. 1+) – Uploads the file in the entity body to the path specified in the URL field • DELETE (HTTP/1. 1+) – Deletes the file specified in the URL field 4
HTTP message • HTTP response message Status line HTTP/1. 1 200 OK Date: Thu, 28 Jan 2016 09: 53: 26 GMT Server: Apache Last-Modified: Thu, 03 Dec 1992 08: 37: 20 Header lines Content-Length: 2217 Connection: close Content-Type: text/html Data <HEADER> <TITLE>The World Wide Web Project</TITLE> </HEADER> <BODY> … 5
HTTP response status codes • 200 OK – Request succeeded, requested object later in this message • 301 Moved Permanently – Requested object moved, new location specified later in this message (Location: ) • 404 Not Found – Requested document not found on this server • 500 Internal Server Error – An unexpected condition was encountered • 503 Service Unavailable – The server is currently unavailable (due to overloading or maintenance) 6
Content • Explore several aspects of the HTTP protocol with Wireshark – Basic HTTP GET/response interaction – The HTTP CONDITIONAL GET/response interaction – Retrieving long documents – HTML documents with embedded objects – HTTP authentication 7
Web cache • A mechanism for the temporary storage (caching) of web documents, such as HTML pages and images, to reduce bandwidth usage, server load, and perceived lag • Clear cache – Google Chrome: Ctrl+Shift+Delete → Clear browsing data – Mozilla Firefox: Ctrl+Shift+Delete → Clear Now – Internet Explorer: Use Chrome or Firefox 8
Practice 1 • Y: Win 32Wireshark. Portable • Visit http: //www 4. comp. polyu. edu. hk/~comp 2322/HTTP-1. html • Question 1 (2 marks for each part in a question) a) b) c) d) e) f) What version(s) of HTTP are your browser and the server running? What language(s) (if any) does your browser indicate that it can accept from the server? What are the IP addresses of your computer and the server? What is the status code returned from the server to your browser? When was the HTML file that you retrieved last modified at the server? How many bytes of content are returned to your browser? 9
Practice 2 • • Clear web cache Visit http: //www 4. comp. polyu. edu. hk/~comp 2322/HTTP-2. html Visit this address again Question 2 – Inspect the contents of the first HTTP GET request a) b) Do you see an “If-Modified-Since” line in the HTTP GET? Did the server explicitly return the contents of the file? How can you tell? c) Do you see an “If-Modified-Since” line in the HTTP GET? If so, what information follows the “If-Modified-Since” header? What is the status code and phrase returned from the server’s response to this second HTTP GET? Did the server explicitly return the contents of the file? Explain. – Inspect the contents of the second HTTP GET request d) e) 10
Practice 3 • Open a new incognito or private window in your browser – Google Chrome: Ctrl+Shift+N – Mozilla Firefox: Ctrl+Shift+P • Visit http: //www 4. comp. polyu. edu. hk/~comp 2322/HTTP 2. html • Visit this address again • Question 3 a) Did the server explicitly return the contents of the file in response to the first HTTP GET request? b) How about for the second HTTP GET request? c) Please explain this behavior. When does the browser clear all the cache when browsing in incognito or private mode? 11
Practice 4 • Clear web cache • Visit http: //www 4. comp. polyu. edu. hk/~comp 2322/HTTP-3. html • Select an HTTP message → Right-click on the TCP layer → Protocol Preferences → Uncheck Allow subdissector to reassemble TCP stream • Question 4 a) b) c) d) How many HTTP GET request messages were sent by your browser? How many data-containing TCP segments were needed to carry the single HTTP response? What is the status code and phrase associated with the response to the HTTP GET request? Are there any HTTP status lines in the transmitted data associated with a TCP-induced “Continuation”? 12
Practice 5 • Clear web cache • Visit http: //www 4. comp. polyu. edu. hk/~comp 2322/HT TP-4. html • Question 5 a) How many HTTP GET request messages were sent by your browser? To which Internet addresses were these GET requests sent? b) Can you tell whether your browser downloaded the two images serially, or whether they were downloaded from the two websites in parallel? Explain. 13
Practice 6 • Clear web cache • Visit http: //www 4. comp. polyu. edu. hk/~comp 2322/HTTP 5. php • Username: wireshark-students • Password: network • Question 6 a) What is the status code and phrase of the server’s response to the initial HTTP GET message from your browser? b) When your browser sends the HTTP GET message for the second time, what new field is included in the HTTP GET message? 14
• In last December, the Internet Engineering Steering Group (IESG) approved a new HTTP status code. • Question 7 – What is the new status code and what is it for? 15
- Slides: 15