-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdraft-inadarei-prefer-transclude-00.txt
More file actions
392 lines (235 loc) · 12 KB
/
draft-inadarei-prefer-transclude-00.txt
File metadata and controls
392 lines (235 loc) · 12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
Network Working Group I. Nadareishvili
Internet-Draft
Intended status: Informational E. Wilde
Expires: July 22, 2018 January 18, 2018
Transclude Preference for the HTTP Prefer Header
inadarei-prefer-transclude
Abstract
The Transclude preference is a registered behavior for the HTTP
Prefer header field. Its purpose is for clients to specify
preferences that certain links in a response should be resolved by
the server, instead of being served as links that the client can
resolve.
Note to Readers
*RFC EDITOR: please remove this section before publication*
The issues list for this draft can be found at
https://github.com/inadarei/draft-prefer-transclude/issues [1].
The most recent draft is at https://inadarei.github.io/draft-prefer-
transclude/ [2].
Status of This Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on July 22, 2018.
Nadareishvili & Wilde Expires July 22, 2018 [Page 1]
Internet-Draft Transclude for HTTP Prefer January 2018
Copyright Notice
Copyright (c) 2018 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(https://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
2. Notational Conventions . . . . . . . . . . . . . . . . . . . 3
3. Transclude Usage Example . . . . . . . . . . . . . . . . . . 3
4. Implementation Considerations . . . . . . . . . . . . . . . . 4
5. Multipart Response Example . . . . . . . . . . . . . . . . . 4
6. Security Considerations . . . . . . . . . . . . . . . . . . . 5
7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 6
8. References . . . . . . . . . . . . . . . . . . . . . . . . . 6
8.1. Normative References . . . . . . . . . . . . . . . . . . 6
8.2. Informative References . . . . . . . . . . . . . . . . . 6
8.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . 7
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 7
1. Introduction
"Prefer Header for HTTP" [RFC7240] defines an HTTP header that can be
used to indicate that particular server behaviors are preferred by
the client but are not required for successful completion of the
request. It further defines several standard Preferences, such as
the "return" preference. The "return" preference lets the server
know that the client would prefer a specific representation of a
resource in a response payload, e.g. full representation vs. a
minimal one.
Preferences like the "return" one are critical for mobile scenarios
as mobile applications are very sensitive to network latency,
throughput and anything that can improve end-user experience, even on
resource-constrained networks. Prefer header allows servers to tune
and optimize its response payload based on client preferences, for
Nadareishvili & Wilde Expires July 22, 2018 [Page 2]
Internet-Draft Transclude for HTTP Prefer January 2018
instance: to only send mobile app a minimal response when it doesn't
need full resource.
The size of the payload is not the only preference that can improve
user-experience in mobile scenarios, however. Closely related to the
size of the payload, is the number of HTTP requests a client needs to
make to get all of the required data. This is the challenge that
"transclude" preference addresses.
When server sends hypermedia responses (e.g. in the case of
hypermedia APIs) some of the response data may be referenced via a
URI link instead of being embedded in the payload itself. The need
to grab data from a link can degrade experience of mobile
applications, since they are forced to make multiple requests to per
single end-user request. This is sometimes referred to as "chatty
interface" and is a significant problem for mobile and Internet of
Things scenarios.
Transclude preference notifies the server that the client would
prefer the server to proactively transclude certain content
represented by links of indicated link relation types. The notion of
"link relation type", in this context is as defined by Web Linking
[RFC8288].
As a result of using a transclude preference, a client receives all
of the required data already embedded in the response output, without
the need to make additional network calls.
2. Notational Conventions
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in [RFC2119].
3. Transclude Usage Example
Following is an example of a client asking server to transclude data
represented at the copyright, edit-form and "other-form" links.
Since "other-form" is not a registered IANA link relation type, the
client is using a URI for identifying the extension link relation
type.
Get /blog/1223 HTTP/1.1
Host: api.example.org
Content-Type: application/json
Prefer: transclude="copyright;edit-form;http://rels.io/other-form"
Vary: Prefer,Accept,Accept-Encoding
Nadareishvili & Wilde Expires July 22, 2018 [Page 3]
Internet-Draft Transclude for HTTP Prefer January 2018
As can be seen from the example, the transclude preference expects
the value to be enclosed in double quotes, if there are multiple link
relation types provided. As required by Web Linking [RFC8288],
registered link relations MUST be indicated by a simple string, while
extension link relation types MUST be indicated with a unique URI
representing that link relation. Multiple link relation types MUST
be separated by semicolon.
Example response may look something like the following:
HTTP/1.1 200 OK
Server: nginx/1.10.3 (Ubuntu)
Date: Sat, 27 Jun 2017 10:07:32 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Vary: Prefer,Accept,Accept-Encoding
Preference-Applied: transclude="copyright;edit-form"
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Content-Type
As can be seen from this output, the server only transcluded
copyright and edit-form link relation types, but not the custom type
client requested. This is because preferences are just suggestions
and server has no obligation related to them. In this case, we can
assume that the server skipped the last link relation type because
maybe it was not familiar with it, or for some other reason.
4. Implementation Considerations
Transclude preference is media-type agnostic. It should work with
any response content-type. The mechanics of transclusion, however
will either depend on capabilities of the response media-type or
require a multi-part response with multiple media types in the
response.
5. Multipart Response Example
Nadareishvili & Wilde Expires July 22, 2018 [Page 4]
Internet-Draft Transclude for HTTP Prefer January 2018
HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Date: Thu, 15 Sep 2017 11:07:32 GMT
Content-type: multipart/mixed; boundary="some boundary string"
--some boundary string
Content-Type: application/hal+json; charset=utf-8
{
"_links": {
"self": { "href": "/orders" },
"edit-form": { "href": "/create" }
},
"currentlyProcessing": 14,
"shippedToday": 20
}
--some boundary string
Content-Type: application/prs.hal-forms+json
{
"_links" : {
"self" : { "href" : "/create" }
},
"_templates" : {
"default" : {
"title" : "Create",
"method" : "post",
"contentType" : "application/json",
"properties" : [
{"name": "title", "required": true,
"prompt": "Title"},
{"name": "completed", "value": "false",
"prompt": "Completed"}
]
}
}
}
--some boundary string--
6. Security Considerations
Specific resources transcluded by a client can introduce security
considerations and concerns beyond those discussed within Prefer
Header for HTTP [RFC7240], or HTTP/1.1 [RFC7230] and its associated
specification documents (see [RFC7230] for the list of associated
works). Implementers need to consider implications of including
supported media types and implement appropriate security measures.
Nadareishvili & Wilde Expires July 22, 2018 [Page 5]
Internet-Draft Transclude for HTTP Prefer January 2018
A server could incur greater costs in attempting to comply with a
transclusion preference. Unconditional compliance from a server
could allow the use of preferences for denial of service. A server
can ignore an expressed preference to avoid expending resources that
it does not wish to commit.
7. IANA Considerations
The HTTP Preference below is being registered with IANA per
Section 5.1 of [RFC7240]:
Preference: transclude Value: Optional Parameters: Description:
Reference: RFC XXXX
8. References
8.1. Normative References
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997,
<https://www.rfc-editor.org/info/rfc2119>.
[RFC7240] Snell, J., "Prefer Header for HTTP", RFC 7240,
DOI 10.17487/RFC7240, June 2014,
<https://www.rfc-editor.org/info/rfc7240>.
[RFC8288] Nottingham, M., "Web Linking", RFC 8288,
DOI 10.17487/RFC8288, October 2017,
<https://www.rfc-editor.org/info/rfc8288>.
8.2. Informative References
[RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
Protocol (HTTP/1.1): Message Syntax and Routing",
RFC 7230, DOI 10.17487/RFC7230, June 2014,
<https://www.rfc-editor.org/info/rfc7230>.
8.3. URIs
[1] https://github.com/inadarei/draft-prefer-transclude/issues
[2] https://inadarei.github.io/draft-prefer-transclude/
Nadareishvili & Wilde Expires July 22, 2018 [Page 6]
Internet-Draft Transclude for HTTP Prefer January 2018
Appendix A. Acknowledgments
Authors' Addresses
Irakli Nadareishvili
114 5th Avenue
New York
United States
Email: irakli@gmail.com
URI: http://www.freshblurbs.com/
Erik Wilde
Email: erik.wilde@dret.net
URI: http://dret.net/netdret/
Nadareishvili & Wilde Expires July 22, 2018 [Page 7]