Last active
January 23, 2018 14:15
-
-
Save bbpennel/e10355fa93993849868a60559edac6a0 to your computer and use it in GitHub Desktop.
Draft proposal for Prefer header to suggest how a server should store and provide access to
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
o Preference: content-resolution | |
o Value: copy, proxy, redirect | |
o Optional Parameters: "content-type", it allows a client to indicate a preferred mimetype for the server to | |
provide in responses for this resource. To be used when the client is unable to provide type information for | |
the message content in the "Content-Type" header. Values defined as in | |
https://tools.ietf.org/html/rfc7231#section-3.1.1.5 | |
o Description: Indicates the client's preference for how the server will store and provide access to the content | |
of a message for a PUT or POST request. When the value is "copy", it indicates that the client prefers that | |
the server store a copy of the content and serve requests for that resource using the copy. When the value is | |
"proxy", it indicates that the client prefers that requests for the content of the resource be proxied by the | |
server from the original location. When the value is "redirect", it indicates that the client prefers that | |
requests for the content of the resource result in a 307 redirect response, directing the client to | |
the original location of the content. | |
o Reference: https://gist.github.com/bbpennel/e10355fa93993849868a60559edac6a0 | |
o Notes: This preference was designed to supplement the functionality of the "Content-Type: message/external-body; | |
access-type=url, url=<url>" header, but could potentially apply to the Content-Location header and other | |
situations. It allows a client to specify a preference for how a server would provide access to content | |
submitted to the server, in this case from an external body at a URL. | |
Proxy Example: | |
Request: | |
PUT /rest/object | |
Content-Type: message/external-body; access-type=URL, URL="http://example.com/image.png" | |
Prefer: message-resolution="proxy" | |
Response: | |
Status: 204 | |
Content-Location: /rest/object | |
Preference-Applied: message-resolution="proxy" | |
Request: | |
GET /rest/object | |
Response: | |
Status: 200 | |
Content-Type: application/octet-stream | |
Content-Location: http://example.com/image.png | |
Body: | |
<binary content from image.png> | |
Copy Example: | |
Request: | |
PUT /rest/object2 | |
Content-Type: message/external-body; access-type=URL, URL="file:/path/to/image" | |
Prefer: message-resolution="copy"; content-type="image/png" | |
Response: | |
Status: 204 | |
Content-Location: /rest/object2 | |
Preference-Applied: message-resolution="copy"; content-type="image/png" | |
Request: | |
GET /rest/object2 | |
Response: | |
Status: 200 | |
Content-Type: image/png | |
Content-Location: file:/path/to/image.png | |
Body: | |
<binary content from image> | |
Redirect Example: | |
Request: | |
PUT /rest/object3 | |
Content-Type: message/external-body; access-type=URL, URL="http://example.com/image.png" | |
Prefer: message-resolution="redirect" | |
Response: | |
Status: 204 | |
Content-Location: /rest/object3 | |
Preference-Applied: message-resolution="redirect" | |
Request: | |
GET /rest/object | |
Response: | |
Status: 307 | |
Location: http://example.com/image.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment