HTTP Flashcards

1
Q

What is a client?

A

A piece of computer hardware or software that accesses a service made available by a server

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

What is a server?

A

A piece of hardware or software that provides functionality for other programs or devices

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

Which HTTP method does a browser issue to a web server when you visit URL?

A

GET method

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

What three thing are on the start-line of an HTTP request message?

A

1) An HTTP method, a verb (GET, PUT, POST) or a noun (HEAD or OPTIONS) describing the action to be performed.

2) The requested target
(absolute path: POST / HTTP/1.1
GET /background.png HTTP/1.0
HEAD /test.html?query=alibaba HTTP/1.1
OPTIONS /anypage.html HTTP/1.0)

(A complete URL aka. Absoluet Form: used with GET when connected to a proxy
ex: GET https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages HTTP/1.1)

(The authority component of a URL, consisting of the domain name and optionally the port prefixed by a ‘:’ , is called the Authority form. Used only with CONNECT when setting up an HTTP tunnel.
ex: CONNECT developer.mozilla.org:80 HTTP/1.1)

(The asterisk form, a simple asterisk ‘*’ is used with OPTIONS, representing the server as a whole
ex: OPTONS * HTTP/1.1)

3) The HTTP version, which defines the structure of the remaining message, acting as an indicator of the expected version to use for the response

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

What are three things are the start-line of an HTTP response message?

A

1) The protocol version
2) A status code, indicating success or failure of the request
3) A status text. A brief, purely informational description of the status code

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

What are HTTP headers?

A

A place to send information between a request and a response

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

Where would you go if you wanted to learn more about a specific HTTP Header?

A

MDN

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

What is client? (recap)

A

Server Requester

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

What is a server? (recap)

A

Receives the response and returns it

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

Which HTTP method does a browser issue to a web server when you visit a URL? (recap)

A

Get

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

What is the difference between http and https?

A

https is secure

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

What is on the first line of an HTTP request message? (recap)

A

method / target / http version

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

What is on the first line of an HTTP response message? (recap)

A

method / target / error or success code

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

What are HTTP headers? (recap)

A

A place to send information between a request and a response

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

Is a body required for a valid HTTP message? (recap)

A

No

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

Main http methods

A

GET, PUT, POST, DELETE

16
Q

What does fetch() return?

A

A promise

17
Q

What is the default request method used by fetch()?

A

GET

18
Q

How do you specify the request method (GET, POST, etc.) when calling fetch?

A

In the option Ex: fetch(‘url’, GET)

19
Q

How does fetch report errors?

A

With a try catch, and when encountering a network error

20
Q

How can useEffect be used to load data for a component?

A

It can be used whenever you want something happening before it loads or when something in the URL is changing

21
Q

What browser function can be used to make HTTP request to a server in React?

A

fetch( )

22
Q

How do you use useEffect to load component data just once when the component mounts?

A

By passing an empty array as a dependency

23
Q

How do you use useEffect to load component data every time the data key changes?

A

By passing the key as a dependency

24
Q

In a large-scale production app, what are some better alternative for loading and managing backend data?

A

React Query and Vercel SWR