This section describes how EDAA uses http headers, specifically eTags, and the Accept header for API version and language negotiation.
Language Negotiation
A consumer of an EDAA may use the http Accept-Language header to specify which languages/locales it would prefer certain human-readable components of the response be translated into. Currently, EDAA defines the Message information item of an Error resource as the only normative aspect that is governed by the Accept-Language header. An EDAA MAY use language preference to alter other aspects of the response formatting.
GET /types?language=da Accept-Language: es, en-gb;q=0.8, en;q=0.7contains a conflict between the language query parameter and the Accept-Language: header. There is no language/locale that matches both criteria. In this case, the server must return an error (406 not acceptable).
JSON Equivalent of Feed and Entry eTags
EDAA implementations are encouraged to support the notion of eTags for cache control and optimistic concurrency control.
EDAA implementations that implement eTags and also support the JSON serialization format described in this page MUST annotate those feeds and entries with eTags. Feed level eTags should be weak eTags and entry level etags should be strong eTags.
{ "etag": 'W/"C0QBRXcycSp7ImA9WxRVFUk."' ... other metadata about the feed "entries":[ { entry ... }, ... etc for all the entries in the feed ], ... }
{ "etag": '“ADEEFO42drp7tKA7QxRDBIL."' other metadata about the entry... , representation of a resource within the content object ... , ... }, ... }
Using eTag in a GET
GET /types/FileServer/instancesand the response might look like:
<?xml version="1.0" encoding="UTF-8"?> <atom:feed ... xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/"B9roqXcycSp7ImA9WxRVDdk."'> ... <atom:link href="https://.../types/FileServer/instances" rel="self”/> ... <atom:entry ... xmlns:gd='http://schemas.google.com/g/2005' gd:etag='“U822F2drp7tKA7QxRD2Ko."'> ... <atom:link rel='self' href='http:.../instances/Fileserver::1234' /> ... </atom:entry> <atom:entry> ... </atom:feed>
GET /types/FileServer/instances If-None-Match: W/"B9roqXcycSp7ImA9WxRVDdk."Then the EDAA could note that the eTag in the If-None-Match header matches the eTag associated with its version of the feed, and if they match, return an http 304 (not modified) status code with an empty response body. Saving processing time on the server side, saving network bandwidth, reducing the latency of the response to the client and saving the client from having to re-process a feed that is no different from the version it already has. Of course, if the eTags don't match then a full response is returned to the consumer with http 200 (ok) status code.
GET /instances/Fileserver::1234 If-None-Match: “U822F2drp7tKA7QxRD2Ko."And the EDAA could check if the eTags match, and if they do, return the 304 response, but if they don't, send a full response with 200 (ok) status.
Using eTag in a PUT or PATCH operation
GET /types/FileServer/instances and the response might look like: <?xml version="1.0" encoding="UTF-8"?> <atom:feed ... xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/"B9roqXcycSp7ImA9WxRVDdk."'> ... <atom:link href="https://.../types/FileServer/instances" rel="self”/> ... <atom:entry ... xmlns:gd='http://schemas.google.com/g/2005' gd:etag='“U822F2drp7tKA7QxRD2Ko."'> ... <atom:link rel='self' href='http:.../instances/Fileserver::1234' /> ... </atom:entry> <atom:entry> ... </atom:feed>At some point in the future, the consumer may wish to use PUT or PATCH to make modifications to the resource. When an EDAA decorates response feeds with eTag elements, then it MUST also require consumers to annotate any resource modification request with an http If-Match header containing the eTag of the resource being modified. For example, to modify the FileServer instance retrieved in the previous example, a PUT request as follows could be formed:
PUT /instances/Fileserver::1234 If-Match: “U822F2drp7tKA7QxRD2Ko." ... body of the PUT contains a partial representation (for update) of a FileServer instanceNote, the content of the If-Match: header is the eTag value contained in the atom:entry corresponding to the resource being updated. The EDAA MUST compare the value of the eTag given in the If-Match header with the current eTag value for the resource. If the values match, the modification operation may proceed. If the values do not match, the EDAA MUST respond with an http 412 (Precondition Failed) response.
If the EDAA provided an eTag with the resource representation, as shown above, and the consumer does not include an If-Match: header in a modification request, then the EDAA MUST reject the request with an http 412 (Precondition Failed) response.