CS 33600 Exam 2 Review The exam is on Monday, May 5, at 12:30 pm. The exam is over the course material that we covered since the first exam. The reading assignments and code examples for the exam are listed on the course web site. Here are a few review problems. Problem 1.) Identify all the parts of the following URLs. http://www.bigcompany.com:42/consumer/products/lookup.php?sku=0&color=greenish http://www.bigcompany.edu:4242/where/was/that/file.scm?x=2+2&bob=a4s56d7v83n https://people.scs.carleton.ca/~lanthier/teaching/COMP1406/Notes/COMP1406_Ch12_NetworkProgramming.pdf#page=6 Problem 2.) What would be the HTTP request message (request line and the most important request headers) for the following URL? http://cs.pnw.edu:80/~rlkraft/cs33600/class.html#2024-03-18 Problem 3.) How does an HTTP server know when it has received the last request header? How does an HTTP client know when it has received the last response header? How does an HTTP server or client know when it has received all of the entity body? An entity body is an array of bytes. An array of bytes can be any kind of data. How does an HTTP server or client know what the bytes in an entity body mean? Problem 4.) Explain why, when a browser is told to GET a single URL, like https://www.pnw.edu/ that single URL can easily lead to many actual HTTP GET requests. Problem 5.) Explain why, when a browser is told to GET this URL, http://pnw.edu/ that URL will lead to more HTTP GET requests than this URL, https://www.pnw.edu/ Problem 6.) If a browser sends the following HTTP request to a server, then what was the (complete) URL in the browser's address bar? GET /~rlkraft/cs33600/dynamic.html?data1=cats&data2=dogs HTTP/1.1 Host: math.pnw.edu Accept: text/html,application/xhtml+xml,application/xml Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9 Cache-Control: no-cache Connection: keep-alive Problem 7.) When a browser needs to send data to a dynamic web application running on an HTTP server, the browser can use either the http GET method or the http POST method. Give two differences between using GET and POST. Problem 8.) What is the meaning of this HTTP response and headers? HTTP/1.0 301 Moved Permanently Location: http://www.MergedCompany.com/ Server: BigIP Connection: Keep-Alive Content-Length: 0 Problem 9.) The next few problems use the Windows curl program. https://curl.se/windows/microsoft.html Explain the difference in the results of this curl command > curl -v -H "Accept-Encoding: gzip" https://www.pnw.edu and this curl command. > curl -v https://www.pnw.edu Problem 10.) Look carefully at the result from this curl command, > curl https://www.google.com/search?q=Rome and this curl command. > curl -A bob https://www.google.com/search?q=Rome What do you think explains the difference? Hint: You can add the -v option to the curl command-lines to get more clues. Problem 11.) Explain the difference in the results of these three curl commands. > curl http://cs.pnw.edu/~rlkraft/cs33600/cs33600.html > curl -H "If-Modified-Since: Mon, 21 Apr 2025 00:00:00 GMT" http://cs.pnw.edu/~rlkraft/cs33600/cs33600.html > curl -H "If-Modified-Since: Mon, 6 Jan 2025 00:00:00 GMT" http://cs.pnw.edu/~rlkraft/cs33600/cs33600.html Hint: Add the -v option to the curl command-lines to get more clues. Problem 12.) Explain the difference in the results of this curl command > curl http://cs.pnw.edu/~rlkraft/cs33600/cs33600.html and this curl command. > curl -H "Range: bytes=1000-1400" http://cs.pnw.edu/~rlkraft/cs33600/cs33600.html Hint: Add the -v option to the curl command-lines to get more clues. Problem 13.) Why doesn't the HTTP protocol use a sentinel value to mark the end of an entity body? Problem 14.) Run the http server from class. http://cs.pnw.edu/~rlkraft/cs33600/for-class/http_server.zip Enter this URL into your browser. http://localhost:8080/static.html#part2 What URL is sent by the browser to the server? Why? What is displayed by the browser? Why? Use curl with the same URL. > curl -v http://localhost:8080/static.html#part2 What URL did curl send to the server? What was sent back by the server to the curl client? What happened to the fragment? Problem 15.) How are the HTTP "Connection: close" and "Connection: keep-alive" headers used? Be sure to explain their use as both a request header and a response header. Problem 16.) (a) If a browser makes an HTTP GET request for the following HTML file, how many other HTTP requests will the browser make? Explain why.

Go to Page 2

Go to Page 3

Go to Page 4

(b) If the original GET request was to this URL http://www.example.com/page1.html then show exactly what the HTTP request message will look like for each one of the additional GET requests. Problem 17.) If a browser makes an HTTP GET request for the following HTML file, how many other HTTP requests will the browser make? Explain why. Home page

Try our HTML form.



Problem 18.) For the following HTML form, give an example of what the HTTP GET request line might look like when the user clicks on the submit button. Hint: Experiment with the html pages from the "public_html" sup-folder of http://cs.pnw.edu/~rlkraft/cs33600/for-class/http_server_ex.zip




19.) The following four URLs all work and will get you to the Google search page. But these URLs are not equivalent to each other. How are they related? Give your answer in terms of the HTTP protocol. That is, what happens when you do an HTTP GET on each of these URLs? http://google.com http://www.google.com https://google.com https://www.google.com Which URL is really the Google search URL? Why? Hint: Load each URL into Chrome with Chrome's Dev-Tools open to its "Network" tab. Or, download each URL using Curl with appropriate command-line options. 20.) (a) What happens if the server says Content-Length is 200 but the server only sends 100 bytes? (b) What happens if the server says Conten-Length is 100 but the server sends 200 bytes? (c) How do the answers to (a) and (b) depend on a persistent connection? Hint: You can modify the source coode to the server HttpServer_v2.java in http://cs.pnw.edu/~rlkraft/cs33600/for-class/http_server.zip so that the server lies about the content length. Then see how the Chrome browser or the Curl client react.