HTTP Methods and Request Messages Quiz

FervidPine avatar
FervidPine
·
·
Download

Start Quiz

Study Flashcards

10 Questions

What does a HTTP status code 301 indicate?

Requested object moved, new location specified

When does a server respond with HTTP status code 404?

Requested document is not found on the server

What does the HTTP response status code 200 signify?

Request succeeded

If a server responds with HTTP status code 400, what does it mean?

Request message is not understood by the server

Which status code would you expect if the requested document is not found on the server?

404 Not Found

In an HTTP response message, what does status code 505 indicate?

HTTP version not supported

If a client receives an HTTP response with status code 301, what action should it take?

Update the location and make a new request

What should a client do if it receives an HTTP response with status code 400?

'Bad Request', do nothing and wait for server to respond again

'HTTP Version Not Supported' is communicated through which HTTP status code?

'505 HTTP Version Not Supported'

'Request Not Found' on the server corresponds to which HTTP status code?

'404 Not Found'

Study Notes

HTTP Request Messages

  • The GET method sends data to the server by including user data in the URL field of the HTTP GET request message, following a '?' (e.g., www.somesite.com/animalsearch?monkeys&banana).
  • The PUT method uploads a new file (object) to the server and completely replaces the file that exists at the specified URL with the content in the entity body of the POST HTTP request message.

HTTP Response Message

  • The response message consists of a status line (protocol, status code, and status phrase), header lines, and data (e.g., the requested HTML file).
  • The status code appears in the first line of the server-to-client response message.

Steps in HTTP

  • The client initiates a TCP connection.
  • The client sends an HTTP request message.
  • The server sends an HTTP response message, which includes the HTML file.
  • The client parses the HTML file, finds referenced objects (e.g., jpeg objects), and repeats steps 1-5 for each object.

RTT (Round Trip Time)

  • RTT is the time it takes for a small packet to travel from the client to the server and back.
  • HTTP response time (per object) consists of one RTT to initiate a TCP connection, one RTT for the HTTP request and first few bytes of the HTTP response, and object/file transmission time.

Non-Persistent HTTP

  • Non-persistent HTTP requires 2 RTTs per object.
  • There is OS overhead for each TCP connection.
  • Browsers often open multiple parallel TCP connections to fetch referenced objects in parallel.
  • Non-persistent HTTP response time = 2RTT + file transmission time.

Persistent HTTP (HTTP 1.1)

  • The server leaves the connection open after sending the response.
  • Subsequent HTTP messages between the same client and server are sent over the open connection.
  • The client sends requests as soon as it encounters a referenced object.
  • Response time is reduced to as little as one RTT for all referenced objects.

HTTP Request and Response Messages

  • There are two types of HTTP messages: request and response.
  • HTTP request messages consist of a request line (GET, POST, HEAD commands), header lines, and an entity body.

HTTP Request Message Format

  • The request line includes the method, URL, and HTTP/1.1.
  • Header lines consist of a header field name, a colon, and a value.
  • The request message is terminated by a carriage return and line feed at the start of a line.

HTTP Methods

  • The POST method sends user input from the client to the server in the entity body of the HTTP POST request message.
  • The HEAD method requests headers (only) that would be returned if the specified URL were requested with an HTTP GET method.

HTTP Response Status Codes

  • 200 OK: the request succeeded, and the requested object is later in this message.
  • 301 Moved Permanently: the requested object was moved, and the new location is specified later in this message (in the Location: field).
  • 400 Bad Request: the request message was not understood by the server.
  • 404 Not Found: the requested document was not found on this server.
  • 505 HTTP Version Not Supported.

Trying out HTTP

  • To try out HTTP, download ncat tools from https://nmap.org/download.html.
  • Use ncat to open a TCP connection to port 80 (default HTTP server port) at a specified website (e.g., www.menofia.edu.eg).
  • Type in a GET HTTP request (e.g., GET /fee/NewsDetails/142317/en HTTP/1.1 Host: www.menofia.edu.eg) and send it to the HTTP server.

Summary

  • This lecture covers how applications communicate through the network, introducing the HTTP protocol with versions 1.0, 1.1, 2, and 3.

Test your knowledge on different HTTP request methods including PUT and GET. Learn about including user data in the URL field, uploading new files to a server, and replacing existing files with POST requests. Explore concepts like status lines, header lines, and data transfer in HTTP protocol.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Use Quizgecko on...
Browser
Browser