Restful Flashcards

1
Q

What is Rest?

A

Representational State Transfer is a software architectural style that defines a set of constraints to be used for creating Web Services.
Web Services that conform to the Rest Architectural style, called Restful Web Services, provide interoperability between computer systems on the net.

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

What makes a service Restful?

A

In the Rest architectural style, data and functionality are considered resources and are accessed using Uniform resource Identifiers (URIs), The resources are acted upon by using a set of simple, well-defined operations.

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

What protocols and data format do Rest services use?

A

JSON is a format, commonly associated with REST services, even though REST itself is format agnostic. That means that, while JSON is the most commonly used format, Rest allows you to user XML, HTML, pure text, any format.

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

What are the architectural constraints of Rest?

A
The 6 constraints are:
Stateless
Client/Server
Cacheable 
Layered Architecture
Uniform Interface
Code on Demand
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Stateless?

A

Each request from client to server must contain all of the information necessary to understand the request, and cannot take advantage of any stored context on the server. Session state is therefore kept entirely on the client.

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

What is Cacheable?

A

Cache constraints require that the data within a response to a request be implicitly or explicitly labeled 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.

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

What is Uniform Interface?

A

By applying the software engineering principle of generality? to the component interface, the overall system architecture is simplified and the visibility of interactions is improved. In order to obtain a uniform interface, multiple architectural constraints are needed to guide the behavior of components.

identification of resources
manipulation of resources through representations
self-descriptive messages
hypermedia as the engine of application state.

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

What is a Layered System?

A

The layered system style allows an architecture to be composed of hierarchical layers by constraining component behavior such that each component cannot “see” beyond the immediate layer with which they are interacting.

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

What is client-server

A

By separating the user interface concerns from the data storage concerns, we improve the portability of the user interface across multiple platforms and improve scalability by simplifying the server.components

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

What is Code on Demand?

A

Rest allows client functionality to be extended by downloading and executing code in the form of Applets or Scripts. This simplifies clients by reducing the number of features required to be pre-implemented.

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

What is Caching?

A

the ability to store copies of frequently accessed data in several places along the request-response path.
By using HTTP headers, a origin server indicates whether a response can be cached and, if so, by whom, and for how long. Caches along the response path can take a copy of a response, but only if the caching metadata allows them to do so.

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

What are the pros and cons of Caching?

A
Optimizing the network using caching imporves the overall quality-of-service in the following ways: 
Reduce bandwidth
Reduce latency
reduce load on servers
Hide network failures
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What should be Cacheable?

A

Get requests by default unless otherwise specified
Post requests are NOT by default, but can be if an Expires or Cache-Control header with a directive, to explicitly allow caching, is added to the response.
Put and Delete requests are NOT cacheable at all.

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

What is Expires? (Caching)

A

The Expires HTTP header specifies an absolute expiry time for a cached representation.
Beyond that time, a cached representation is considered stale and must be re-validated with the origin server.

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

What is Cache-Control?

A

The header value comprises one or more comma-separated directives. The directives determine whether a response is cacheable, and if so, by whom, and for how long.

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

What is Compression

A

Compression, like encryption, is something that happens to the resource representation in transit and must be undone before the client can use the representation.

17
Q

What is Accept-Encoding? (Compression)

A

(Request)The Accept-Encoding header says what kind of compression algorithms the client understands. two standards values are compress and gzip.

GET /employees HTTP/1.1
Host: www.domain.com
Accept: text/html
Accept-Encoding: gzip,compress

If the server cannot send a response which is acceptable according the AE header, then the server SHOULD send an error response with the 406(Not Acceptable).

18
Q

What is Content-Encoding? (Compression)

A

(Response) If the server understands on of the compression algorithms form Accepting-Encoding, it can use that algorithm to compress the representation before serving it. When successfully compressed, server lets the client know the client know of the encoding scheme with the Content-Encoding header.

200 OK
Content-Type: text/html
Content-Encoding: gzip

If the content-coding of an entity in a request message is not acceptable to the origin server, the server SHOULD respond with a status code of 415 (Unsupported Media Type)
Note: if multiple content encodings have been applied to an entity, all the encodings MUST be listed in the order in which they were used.

19
Q

What is Content Negotiation?

A

The process of selecting the best representation for a given response when there are multiple representations.available.

20
Q

What is Server-Driven Negotiation?

A

Server-Driven negotiation is the selection of the best representation for a response made by an algorithm located at the server.
Practically, you will NOT find mush usage of server-side negotiations because of the assumptions made about client expectations.

21
Q

What is Agent-Driven Content Negotiation? (client)

A

Agent driven content negotiation rely on usage of HTTP request headers or resource URI patterns.

22
Q

What is COntent negotiation using HTTP headers?

A

At server side, an incoming request may have an entity attached to it. To determine it’s type, server uses the HTTP request

header Content-Type.

Content-Type: applicaiton/json
to determine what type of representation is desired at client side, HTTP header ACCEPT is used.

Accept: application/xml

if no Accept header is present in the request, the server can send pre-configured default representation type text/html is the default.

Another way to pass content type information to the server, the client may use the specific extension in resource URIs.

http://rest.api.com/v1/employees/20423.json

23
Q

What is HATEOAS Driven Rest?

A

Hypermedia as the Engine of Application State is a constraint of the REST application architecture that keeps the RESTful style architecture unique from most other network application architectures.
It lets us use the hypermedia links in the response contents. It allows the client to dynamically navigate to the appropriate resources by traversing the hypermedia links.

HTTP GET http://api.domain.com/management/departments/10

{
    "departmentId": 10,
    "departmentName": "Administration",
    "locationId": 1700,
    "managerId": 200,
    "links": [
        {
            "href": "10/employees",
            "rel": "employees",
            "type" : "GET"
        }
    ]
}

or

HTTP/1.1 200 OK

Link: <10/employees>; rel=”employees”

24
Q

What is Idempotent? (Rest)

A

A Restful Web Service is idempotent when making multiple identical requests has the same effect as making a single request.

25
Q

What is identification of resources

A

Individual resources are identified in requests, for example using URIs in web-based REST systems. The resources themselves are conceptually separate from the representations that are returned to the client. For example, the server may send data from its database as HTML, XML or JSON, none of which are the server’s internal representation, and it is the same one resource regardless.

26
Q

What is Manipulation of resources through representations?

A

When a client holds a representation of a resource, including any metadata attached, it has enough information to modify or delete the resource.

27
Q

What is self-descriptive messages?

A

Each message includes enough information to describe how to process the message. For example, which parser to invoke may be specified by an Internet media type (previously known as a MIME type). Responses also explicitly indicate their cacheability.