Designing Representations Flashcards

(14 cards)

1
Q

What HTTP headers do you send in a request to a server or in a response to a client?

A

Content-Type, Content-Length, Content-Language, Content-MD5, Content-Encoding, Last-Modified

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

When you receive a request withouth the content-type header, what do you do?

A

Return error code 400 (Bad Request)

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

How do you avoid Character Encoding Mismatch in representations?

A

Use the charset parameter:

Content-Type: application/xml;charset=UTF-8

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

Explain the difference between a resource and a representation

A

A resource is an abstract entity that is identified by a URI. A representation is concrete and real since that is what you program to and operate upon in clients and servers.

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

How do you design a representation using HTTP?

A

Use the HTTP envelope format to include the right headers and when there is a body for the representation, choose a media type and design a format for the body.

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

What data do you include in JSON-formatted representations?

A
Include a self link to the resource, and include identifiers for each of the application domain entities that make up the resource.
{
"link" : {
     "rel" : "self",
     "href": "http://..."
    }
}
If an object in the representation is localized, add a property to indicate the language its contents are localized in.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What data do you include in representations of collection resources?

A

A self link to the collection resource.
If the collection is paginated and has a next page, a link to the next page.
If the collection is paginated and has a previous page, a link to the previous page.
An indicator of the size of the collection

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

How do you keep collections homogenous?

A

Avoid resource specific information that is not common accross other resource within the same collection.

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

What are portable data formats and why do u use them in representations? What data types are there?

A

Data formats that eliminate interoperability errors.

Numbers, Countries and territories, currencies, Date and times, language tags, time zone identifiers.

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

When do you use entity identifiers?

A

For each of the application domain entities included in the representation of a resource, include identifiers formatted as URNs.
Because it will future-proof your application when it needs to integrate with non-HTTP web services.

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

Why use URN’s as entity identifiers?

A

To maintain the uniqueness through application domains

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

How do you encode binary data in representations that also contain textual data?

A

Use multipart media types (e.g. multipart/mixed).

Content-type: multipart/mixed; boundary=”abcd”

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

When to serve HTML representations?

A

For resources that are expected to be consumed by end users. Avoid for machine clients.
To enable web crawlers and such software, use microformats or RDFa to annotate data within the markup.

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

How do you return errors to clients?

A

For errors due to client inputs, return a representation with a 4xx status code. For server implementation errors, return 5xx status code. In both cases, include a Date header.
Add Link header when debug/help information is available.
If server logging is enabled, include the log id so that the client can communicate effectively.

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