Requests & Responses Flashcards

1
Q

Define HTTP Request Methods

A

*HTTP defines several request methods that indicate the desired action to be performed on a resource.
*Common HTTP request methods include GET, POST, PUT, DELETE, PATCH, HEAD, and OPTIONS.
*Each method has a specific purpose, such as retrieving data (GET), submitting data (POST), updating data (PUT, PATCH), or deleting data (DELETE).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

Define HTTP Headers

A

*HTTP headers are additional pieces of information sent between the client and server along with the request or response.
* Headers provide metadata about the request or response, such as content type, content length, caching directives, authentication credentials, etc.
* Examples of common headers include Content-Type, Content-Length, Accept, User-Agent, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Define HTTP Status Codes

A
  • HTTP status codes are three-digit numbers returned by a server in response to a client’s request.
  • They indicate the success, failure, or other status of the request.
  • Examples include 200 (OK), 404 (Not Found), 500 (Internal Server Error), etc.
    Status codes are grouped into categories like 1xx (Informational), 2xx (Success), 3xx (Redirection), 4xx (Client Error), and 5xx (Server Error).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Expand on HTTP Request Structure

A
  • An HTTP request consists of a request line, headers, an optional body, and a blank line separating the headers and body.
  • The request line includes the request method, URI, and HTTP version.
  • Headers provide additional information about the request, and the body carries optional data (e.g., form data or JSON payload) for POST or PUT requests.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the HTTP Response Structure

A
  • An HTTP response consists of a status line, headers, an optional body, and a blank line separating the headers and body.
  • The status line includes the HTTP version, status code, and a brief status message.
  • Headers provide metadata about the response, and the body contains the actual data returned by the server (e.g., HTML content, JSON data).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Elaborate on the GET Request Method

A
  • The GET method is used to request data from a specified resource.
  • It sends data in the URL’s query string, making it visible in the browser’s address bar.
  • GET requests are idempotent, meaning they produce the same result regardless of how many times they are repeated.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How are path parameters defined in Django?

A
  • Variables within the URL path that define specific resource identifiers.
  • Example: ‘/users/{username}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the response codes for redirection?

A
  • 301: Moved Permanently - Resource has been permanently moved to a new location
  • 302: Found - Resource temporarily moved to a different location
How well did you know this?
1
Not at all
2
3
4
5
Perfectly