The Anatomy of the Web Flashcards
(21 cards)
What is the core of all network
the HTTP protocol
What is the HTTP protocol?
The core of API design and communication over the network is the HTTP protocol
The HTTP protocol is a web standard used to communicate over the internet with services
HTTP is the glue of the internet
What is the HTTP flow?
The HTTP flow is a simple flow that allows clients communicate with servers. The following steps are performed
1) Open a TCP connection: The TCP connection is used to send a request, or several, and receive an answer.
2) Send an HTTP message: HTTP messages (before HTTP/2) are human-readable
3) Read the response sent by the server, such as:
What is a HTTP request?
An HTTP request is when a service is asking another service for information.
Usually from a client to a server.
A request contains a
- A method, the operation that is asked for
- Headers, describe the request and contain info about authentication
- A body, re-request data, only present when we want to update a resource
What are HTTP Methods?
HTTP methods are a set of request methods to indicate the desired action to be performed for a given resource. They are also known as HTTP verbs
What are HTTP verbs?
HTTP verbs are another name for HTTP methods
GET, POST, PUT and DELETE
What are the most important HTTP methods?
GET - Used to retrieve data/get a resource
POST - used to send data / create objects
PUT - Used to update data
PATCH - Used to make partial updates to a resource
DELETE - Used to delete a resource
What are HTTP Headers?
HTTP Headers let the client and the server pass additional information with an HTTP request or response.
What are the important HTTP Headers?
- Accept: tells web service what kind of response the client is accepting
- Content-type: Tells the client/server what the format of the data is being sent in ex JSON, used in POST and PUT requests
- Cache-control: Specifies how the response can be cached, used in later requests
- Authorization: Usually sent by the client, sends a token to be granted access to a resource
What is an HTTP response?
An HTTP response is sent by the server to the client, the responses are formed by
- Status code: indicates what the current status of the response is
- Headers: Contains information about the content, caching, cookies, etc
- Body: The actual data of the response, HTML, JSON, plain text, etc
What is an HTTP status code?
The status code is a message which contains information about the status of the response.
- Successful response (200-299)
- Redirects (300-399)
- Client Errors (400 - 499)
- Server Errors (500-599)
What are the most important status codes?
500 - Internal Server Error
200 - OK
301, 302 - Redirected
401 - Not Authorized –> Authorization is missing or falling
403 -> Forbidden
404 –> The content/resource is not found on the server
What is CORS?
Cors is a system that determines whether the browsers block frontend JS code from accessing responses for requests to another domain, usually fixed by sending the right headers.
What does REST stand for?
REST stands for
Representational State Transfer
What is REST?
REST is an architectural style for web API’s in order to make them simpler, easier to build, and easier to consume.
What is the difference between REST and HTTP
REST != HTTP
HTTP is how clients and servers communicate
REST is the shape of that communication
HTTP is the pen, paper, and the envelope
REST is the introduction, date, content, and signature
What does REST offer?
REST offers us all the CRUD operations Create Retrieve Update Delete
What are some of the properties of RESTful API’s?
A RESTfull API is:
stateless –> every request can be understood in isolation, by itself, so is not necessary to save anything on the server
cacheable –> clients can reuse data in later requests
uniform -> rest is built around resources and applies many clean code principles: separation of concerns, clear boundaries, etc.
What is a REST Resource?
The main concept in REST is a resource. Anything can be a resource: an object (e.g. a person, transactions), images, documents, and so on.
What is a URI?
Each Resource has a unique address called a URI: Uniform Resource Identifier, which is built in the following way:
:////
Example:
http://api.example.com/devices/234
What is Base64 ?
Base64 is a way to take any form of data and transform it into a long string of plain text so that we can send it through the internet.