Web Technology Basics
Which of the following correctly lists the elements in the first line (the request line) of an HTTP/1.1 request?
- AThe method, the request target (such as a path) and the HTTP version
- BThe HTTP version, the status code and a short reason phrase
- 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.