introduction Flashcards

1
Q

make a simple HTTP request using the curl command and analyze the output.

curl -iX GET https://reqres.in/api/users/1

A

The server response has HTTP headers and a message body.

Response headers as key/value pairs

The first line is the HTTP status code

One of the keys is a content-type and has a corresponding value

One of the keys is a set-cookie and has a corresponding value

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

Cookies are

A

a unique identification number that help us keep track of our activity on different web pages.

When you first visit the website, the server assigns the unique identification number to the client. After the cookie is set, the client will always request the server using the cooki

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

The second part of the HTTP response is

A

the message body, which is in the JSON format.

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

The curl command is a command-line tool used to transfer data to or from a server,

A

with the help of any of the supported protocols (HTTP, FTP, IMAP, POP3, SCP, SFTP, SMTP, TFTP, TELNET, LDAP or FILE)

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

HTTP resources are identified and located on the network by

A

Uniform Resource Locators (URLs), using the Uniform Resource Identifiers (URIs) schemes HTTP and HTTPS.

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

https://www.educative.io/explore

A

https – protocol ( Secure HTTP )
www – subdomain
educative.io – domain name
/explore – service end point

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

HTTP methods are designed to enable communications between clients and servers. We will discuss the most commonly used HTTP methods in the next few lessons.

A

GET
POST
PUT
DELETE

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

The GET method is used by the client to

A

fetch the data from the server.

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

By default, curl requests the URL using the GET method. To request the specific URL using the POST, DELETE or PUT methods,

A

we have to use the -X right after the curl command and specify the name of a particular method.

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

The output is a JSON response returned from the server for the requested specified resource.

A

A JSON format will have a key/value pair that represents the data enclosed by curly braces.

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

Using the -X switch will just show us the

A

HTML content in the form of the message body.

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

The -iX switch will show us a

A

response header as well as HTML content in the form of the message body

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

the -I switch will just show us

A

the response header.

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

The HTTP POST method sends data to the server to

A

create a new resource.

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

curl -iX POST -H “Content-Type: application/json” -d ‘{ “email”: “eve.holt@reqres.in”, “password”: “pistol” }’ https://reqres.in/api/register

A

-iX is for HTTP Method

-H is short for –header

-d for –data

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

The HTTP PUT method will

A

update an existing resource or create a new resource on the server, (depending on the request payload.)

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

curl -X PUT -d ‘{“title”:”This is an updated post”}’ https://jsonplaceholder.typicode.com/posts/1

A

-X is for HTTP Method
-d for –data

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

The HTTP DELETE method

A

deletes the specified resource on the server.

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

The response of DELETE request is empty { } JSON and the HTTP response status code is 204 OK. which means

A

that the resource is deleted

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

HTTP requests are

A

messages sent by the client to initiate an action on a resource identified by a given URL over the network

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

The components of an HTTP request are as below

A

The method to be applied to the resource – an HTTP method (like GET, PUT, POST HEAD or OPTIONS)

The resource identifier – resource identified by a given request URL.

Headers (optional) – headers are the information sent to the server in the form of key/value pairs, which contains the details of what the browser wants and will accept from the server.

Params (optional) – used for sending additional data to the server. For example, a query parameter.

Message body (optional) – These are additional information required by the server to process current requests properly. For example, a file type of JSON or XML sent in the case of a POST or PUT method request.

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

After receiving and processing an HTTP request message, a server responds with

A

an HTTP response message

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

The response returned from the server may contains

A

A status-line ( contains HTTP version and HTTP Status code ) – HTTP/2 200

Headers – these are general, response, or entity fields.

Response message body – a message in the form of a JSON, which returns the data associated with the post (id =1 )

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

In a server’s HTTP response, status codes indicate

A

whether a specific HTTP request has been successfully completed or an error has occurred.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
The HTTP response status codes are divided into 5 categories
1xx: informational 2xx: success 3xx: redirection 4xx: client error 5xx:server error
26
200 OK
The request has succeeded.
27
201 Created
The request has been fulfilled and a new resource has been created.
28
202 Accepted
The request has been accepted for processing, but the processing has not been completed.
29
204 No Content
The request has succeeded and there is no content for the response message body.
30
301 Moved Permanently
The target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs.
31
302 Found
The target resource resides temporarily under a different URI.
32
400 Bad Request
The server cannot process the request due to a bad/invalid request from a client (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
33
401 Unauthorized
The request lacks valid authentication credentials for the target resource.
34
403 Forbidden
There is an authorization error on the server.
35
404 Not Found
The origin server did not find a current representation for the target resource.
36
500 Internal Server Error
The server encountered an unexpected condition.
37
502 Bad Gateway
The server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request.
38
503 Service Unavailable
The server is currently unavailable to handle the request.
39
504 Gateway Timeout
The server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request.
40
What are HTTP headers?
basically a key-value, where its key is a case-insensitive string and value is a single or array of string. to pass some additional information through a request or a response.
41
Types of HTTP headers
General headers Request headers Response headers Entity headers
42
General headers
used for both request and response and there is no relation to the message data
43
Request headers
client headers, sent during the HTTP request and they contain information about the resource to be fetched.
44
Response headers
server headers and are part of the HTTP response. They give more details about the server resource context.
45
Entity headers
these headers give meta-information about the content of the body of the message like MIME type, Content-length, etc.
46
-I options in the curl command.
show only response headers from the web server in the form of key/value pairs. There will be no response message body shown
47
What are HTTP parameters?#
When a client uses the HTTP GET method to request a certain resource from the web server, the client may also send certain parameters through the requested URL in the form of a query parameter, path parameter, or a form parameter.
48
Query parameter#
The query parameter is a name-value pair and is the part of a requested GET URL. curl -X GET https://reqres.in/api/users?page=2
49
path parameter
part of a requested GET URL path curl -X GET https://reqres.in/api/users/2
50
Form parameter#
In an HTTP POST request a certain piece of information is sent as a form parameter in the form of a name-value pair. The client sends the form parameters in the requested body in the format that the Content-Type header field specifies. curl -iX POST --form "note=test" --form upfile=@sample.txt "content-type: multipart/form-data" https://cgi-lib.berkeley.edu/ex/fup.cgi The HTTP response contains the headers and the file content in the HTML format.
51
REST, or Representational State Transfer, is an
architectural design that defines a set of rules for creating web services that interact between systems.
52
Web services that follow REST architecture are termed
‘RESTful web services’
53
RESTful system consists of two major components:
A server that hosts the resources A client that connects to the server to fetch the resources
54
REST uses HTTP or HTTPS to exchange data between client and server using
HTTP methods – GET, POST, UPDATE, DELETE, HEAD, PATCH, etc.
55
benefit from the loose coupling between the server and the client when REST is followed
Simplicity Light-weight Architecture is similar to Web Scalability
56
Simplicity benefit for REST architecture
REST web services are easy and simple to develop compared to SOAP web services
57
Light-weight benefit for REST architecture
REST advocates simple communication with the server over HTTP that supports plain XML, JSON formats in comparison to SOAP which supports only XML
58
"Architecture is similar to Web" benefit for REST architecture
developers who understand the web can easily understand and develop RESTful web services
59
Scalability benefit for REST architecture
conversational state that allows us to easily add multiple instances of the components or application behind load balancers
60
A RESTful service needs to comply with
the following 6 guiding constraints: Client–Server Stateless Cacheable Uniform Interface Layered System Code on-demand
61
Client–Server constraints for a RESTful service
separation of concerns By following this principle, we can improve the: portability of the user interface across platforms scalability by simplifying the server component
62
Stateless constraints for a RESTful service
each request from the client must be sent to the server with all the necessary information to understand the request
63
Cacheable constraints for a RESTful service
cache constraints require that the data within a response to a request be implicitly or explicitly denoted as cacheable or non-cacheable If a response is cacheable, then a client cache is given the right to reuse that response data for later, equivalent requests. This allows us to minimize the network calls made to the server.
64
Uniform Interface constraints for a RESTful service
It simplifies and decouples the architecture of the system, allows us to independently scale the components, and improve the interactions between components and other systems.
65
Layered System constraints for a RESTful service
allows an architecture to be divided into a number of hierarchical layers or tiers by constraining each of the layer’s behavior such that each layer cannot access beyond the immediate layer with which they are interacting with.
66
Code on-demand constraints for a RESTful service
REST allows client functionality to be extended by downloading executable scripts that can be executed on client-side
67
The four architectural constraints that RESTful system should follow in order to have a uniform interface are:
resource identification manipulation of resources through representations self-descriptive messages hypermedia as the engine of application state (HATEOS)
68