HTTP Flashcards
What is a client?
A piece of computer hardware or software that accesses a service made available by a server
What is a server?
A piece of hardware or software that provides functionality for other programs or devices
Which HTTP method does a browser issue to a web server when you visit URL?
GET method
What three thing are on the start-line of an HTTP request message?
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
What are three things are the start-line of an HTTP response message?
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
What are HTTP headers?
A place to send information between a request and a response
Where would you go if you wanted to learn more about a specific HTTP Header?
MDN
What is client? (recap)
Server Requester
What is a server? (recap)
Receives the response and returns it
Which HTTP method does a browser issue to a web server when you visit a URL? (recap)
Get
What is the difference between http and https?
https is secure
What is on the first line of an HTTP request message? (recap)
method / target / http version
What is on the first line of an HTTP response message? (recap)
method / target / error or success code
What are HTTP headers? (recap)
A place to send information between a request and a response
Is a body required for a valid HTTP message? (recap)
No
Main http methods
GET, PUT, POST, DELETE
What does fetch() return?
A promise
What is the default request method used by fetch()?
GET
How do you specify the request method (GET, POST, etc.) when calling fetch?
In the option Ex: fetch(‘url’, GET)
How does fetch report errors?
With a try catch, and when encountering a network error
How can useEffect be used to load data for a component?
It can be used whenever you want something happening before it loads or when something in the URL is changing
What browser function can be used to make HTTP request to a server in React?
fetch( )
How do you use useEffect to load component data just once when the component mounts?
By passing an empty array as a dependency
How do you use useEffect to load component data every time the data key changes?
By passing the key as a dependency
In a large-scale production app, what are some better alternative for loading and managing backend data?
React Query and Vercel SWR