General Flashcards

1
Q

What are HTTP methods?

A

HTTP methods are a set of standardized request methods used to indicate the desired action to be performed on a specific resource.

CRUD PGPD
CREATE => POST
READ => GET
UPDATE => PUT/PATCH
DESTROY => DELETE

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

GET

A

Used to retrieve data from the server. It’s a safe method, meaning it doesn’t have side effects and doesn’t change the state of the resource. It should only fetch data.

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

POST

A

Used to submit data to the server to create a new resource. It’s not idempotent, which means making the same request multiple times might result in different outcomes.

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

PUT

A

Used to update an existing resource or create a new resource if it doesn’t exist. It’s idempotent, so making the same request repeatedly has the same effect as making it once.

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

PATCH

A

Used to apply partial modifications to a resource. Unlike PUT, which updates an entire resource, PATCH only updates parts of a resource.

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

DELETE

A

As the name suggests, it’s used to delete a specified resource. It should be idempotent, meaning repeated calls to delete the same resource should have the same effect as a single call.

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

HEAD

A

Similar to the GET method, but it only retrieves the headers of a resource, not the actual data. This is useful when you want to check if a resource exists or to get metadata about a resource without downloading the entire content.

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

OPTIONS

A

Describes the communication options for the target resource. It returns the HTTP methods that the server supports for a specific URL

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

CONNECT

A

Primarily used in a proxy server environment. It establishes a network connection for use with HTTP/1.1.

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

TRACE

A

Performs a diagnostic loop-back test along the request path. It’s used for debugging purposes.

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

What does POST and PUT do, and what are their differences?

A

POST is primarily used to create a new resource. Making the same POST request multiple times can result in different outcomes.

PUT is used to update an existing resource or create a resource if it doesn’t already exist. Making the same PUT request repeatedly will have the same effect as making it once.

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

What does an HTTP request contain?

A

An HTTP request is a structured message comprising a request line, headers, and optionally, a body.

It is a message sent by the client to the server to fetch a resource, submit data, or perform other operations

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

What does a request - request line contain?

A

This is the first line in the HTTP request and consists of:
a. HTTP Method (or Verb): Indicates the desired action to be performed on the resource.
(e.g., GET, POST, PUT, DELETE).
b. Request URI (or URL): Specifies the path to the resource on the server.
c. HTTP Version: Indicates the version of HTTP being used (e.g., HTTP/1.1).

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

What does a request header contain?

A

These provide meta-information about the request. They are categorized into:
a. General Headers: These headers are present in both request and response messages but are not directly associated with the data in the message body (e.g., Cache-Control, Connection).
b. Request Headers: Provide additional information about the resource to be fetched or about the client (e.g., Accept, Host, User-Agent).
c. Entity Headers: Provide information about the body of the resource, like its length or type (e.g., Content-Type, Content-Length).

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

What does a request body (or payload) contain?

A

This is optional and contains data that needs to be sent to the server. For instance, data submitted through an HTML form using the POST method will be sent in the request body.

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

Is it possible to make a post request via get? Why or Why not?

A

No, you cannot make a POST request via GET.

A GET request is designed to retrieve data without causing side-effects, while a POST request is used to submit data to a server, potentially causing a change in the server’s state.

Making the same GET request multiple times should yield the same result without causing any side effects, while it does not with a POST.

17
Q

Explain data transmission for GET vs POST.

A

In a GET request, data is appended to the URL as query parameters. There’s a length limit to URLs, which varies depending on browsers and servers, but is generally much shorter than the amount of data you can send in a POST request body. If you tried to send a large amount of data via GET, you could exceed this limit

18
Q

Explain security for a GET vs POST request.

A

Data sent in a GET request’s URL can be logged by web servers, cached, or seen in browser history. Sensitive data, like passwords or personal information, should not be sent this way.

POST requests keep data in the request body, providing a layer of obscurity

19
Q

What is the maximum size of a URL?

A

The maximum size of a URL is not defined by the HTTP protocol itself. About 2048 characters.

Most modern web browsers have a URL length limit of around 2,000 to 4,000 characters