Web Technology Basics

Which of the following correctly lists the elements in the first line (the request line) of an HTTP/1.1 request?

  1. AThe method, the request target (such as a path) and the HTTP version
  2. BThe HTTP version, the status code and a short reason phrase
  3. CThe source IP address, the destination port number and the method
Show answer and explanation

Answer: A. The method, the request target (such as a path) and the HTTP version

An HTTP request consists of the request line, the headers (one "Name: value" per line), a blank line and the body, in that order. For example, "GET /docs/index.html HTTP/1.1" is a line that requests /docs/index.html with the GET method. In HTTP/1.1 the Host header must also be sent, so that the server can tell which site a request is for even when several sites are run on the same IP address. The first line of a response is the status line, which lists the version, the status code and the reason phrase, as in "HTTP/1.1 200 OK".

  • A. Correct. For example, "GET /docs/index.html HTTP/1.1".
  • B. These are the elements of the first line of a response (the status line).
  • C. The IP address is carried in the IP header and the port number in the TCP header; they are not part of the HTTP request line.
Practice this topic Back to topic

Books on Web Technology Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Web Technology Basics questions

  1. Among HTTP methods, which of the following is not "safe" (not intended to change the state of resources on the server) but is "idempotent" (sending the same request any number of times leaves the same state as sending it once)?
  2. Which of the following correctly pairs an HTTP status code with its meaning?
  3. On a members-only website, an ordinary member who is logged in requests a page that only administrators may access. The server knows who the user is but does not allow access to this page. Which of the following status codes is most appropriate to return?
  4. A web API returns data in JSON format as the body of its response. Which of the following headers is generally added to the response to indicate the format of the body?
  5. A browser requests an image it received earlier once again, putting the ETag value from that earlier response into the If-None-Match header. If the image on the server has not changed, which of the following is the correct server response?