Self-descriptive messages

Let's look at the response of the following call:

https://api.nytimes.com/svc/books/v3/lists.json?api-key={your_api_key}&list=hardcover-fiction

As we mentioned previously, the response is a representation of the data, either stored in a data source or obtained from another system. In any case, some information is missing: how does the client know the format of the response? This kind of information is usually written in the response header. For example, here are all the headers of the previous request:

accept-ranges: bytes
access-control-allow-headers:Accept, Content-Type, X-Forwarded-For, X-Prototype-Version, X-Requested-With
access-control-allow-methods: GET, OPTIONS
access-control-allow-origin: *
access-control-expose-headers: Content-Length, X-JSON
age: 0
connection: keep-alive
content-length: 14384
content-type: application/json; charset=UTF-8
date: Tue, 03 Jul 2018 12:47:08 GMT
server: Apache/2.2.15 (CentOS)
vary: Origin
via: kong/0.9.5
x-cache: MISS
x-kong-proxy-latency: 4
x-kong-upstream-latency: 29
x-ratelimit-limit-day: 1000
x-ratelimit-limit-second: 5
x-ratelimit-remaining-day: 988
x-ratelimit-remaining-second: 4
x-varnish: 63737329

The headers part tells the client that the response should be processed using a specific content-type; in this case, application/json. It also provides information about encoding, caching, and related meta information, such as the age header, which contains the time in seconds that the object has been in the proxy cache.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.34.146