idnits 2.17.1
draft-ietf-httpbis-jfv-00.txt:
Checking boilerplate required by RFC 5378 and the IETF Trust (see
https://trustee.ietf.org/license-info):
----------------------------------------------------------------------------
No issues found here.
Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt:
----------------------------------------------------------------------------
No issues found here.
Checking nits according to https://www.ietf.org/id-info/checklist :
----------------------------------------------------------------------------
** The document seems to lack an IANA Considerations section. (See Section
2.2 of https://www.ietf.org/id-info/checklist for how to handle the case
when there are no actions for IANA.)
== There are 1 instance of lines with non-RFC2606-compliant FQDNs in the
document.
Miscellaneous warnings:
----------------------------------------------------------------------------
== The copyright year in the IETF Trust and authors Copyright Line does not
match the current year
-- The document date (June 24, 2016) is 2862 days in the past. Is this
intentional?
Checking references for intended status: Proposed Standard
----------------------------------------------------------------------------
(See RFCs 3967 and 4897 for information about using normative references
to lower-maturity documents in RFCs)
** Obsolete normative reference: RFC 7159 (Obsoleted by RFC 8259)
** Obsolete normative reference: RFC 7230 (Obsoleted by RFC 9110, RFC 9112)
** Obsolete normative reference: RFC 7231 (Obsoleted by RFC 9110)
-- Obsolete informational reference (is this intentional?): RFC 5987
(Obsoleted by RFC 8187)
-- Obsolete informational reference (is this intentional?): RFC 7235
(Obsoleted by RFC 9110)
Summary: 4 errors (**), 0 flaws (~~), 2 warnings (==), 3 comments (--).
Run idnits with the --verbose option for more detailed information about
the items above.
--------------------------------------------------------------------------------
2 HTTP Working Group J. Reschke
3 Internet-Draft greenbytes
4 Intended status: Standards Track June 24, 2016
5 Expires: December 26, 2016
7 A JSON Encoding for HTTP Header Field Values
8 draft-ietf-httpbis-jfv-00
10 Abstract
12 This document establishes a convention for use of JSON-encoded field
13 values in HTTP header fields.
15 Editorial Note (To be removed by RFC Editor before publication)
17 Discussion of this draft takes place on the HTTPBIS working group
18 mailing list (ietf-http-wg@w3.org), which is archived at
19 .
21 Working Group information can be found at ;
22 source code and issues list for this draft can be found at
23 .
25 The changes in this draft are summarized in Appendix A.
27 Status of This Memo
29 This Internet-Draft is submitted in full conformance with the
30 provisions of BCP 78 and BCP 79.
32 Internet-Drafts are working documents of the Internet Engineering
33 Task Force (IETF). Note that other groups may also distribute
34 working documents as Internet-Drafts. The list of current Internet-
35 Drafts is at http://datatracker.ietf.org/drafts/current/.
37 Internet-Drafts are draft documents valid for a maximum of six months
38 and may be updated, replaced, or obsoleted by other documents at any
39 time. It is inappropriate to use Internet-Drafts as reference
40 material or to cite them other than as "work in progress."
42 This Internet-Draft will expire on December 26, 2016.
44 Copyright Notice
46 Copyright (c) 2016 IETF Trust and the persons identified as the
47 document authors. All rights reserved.
49 This document is subject to BCP 78 and the IETF Trust's Legal
50 Provisions Relating to IETF Documents
51 (http://trustee.ietf.org/license-info) in effect on the date of
52 publication of this document. Please review these documents
53 carefully, as they describe your rights and restrictions with respect
54 to this document. Code Components extracted from this document must
55 include Simplified BSD License text as described in Section 4.e of
56 the Trust Legal Provisions and are provided without warranty as
57 described in the Simplified BSD License.
59 Table of Contents
61 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3
62 2. Data Model and Format . . . . . . . . . . . . . . . . . . . . 3
63 3. Sender Requirements . . . . . . . . . . . . . . . . . . . . . 4
64 4. Recipient Requirements . . . . . . . . . . . . . . . . . . . . 5
65 5. Using this Format in Header Field Definitions . . . . . . . . 5
66 6. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
67 6.1. Content-Length . . . . . . . . . . . . . . . . . . . . . . 5
68 6.2. Content-Disposition . . . . . . . . . . . . . . . . . . . 6
69 6.3. WWW-Authenticate . . . . . . . . . . . . . . . . . . . . . 7
70 7. Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . 8
71 8. Deployment Considerations . . . . . . . . . . . . . . . . . . 8
72 9. Internationalization Considerations . . . . . . . . . . . . . 8
73 10. Security Considerations . . . . . . . . . . . . . . . . . . . 8
74 11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 9
75 11.1. Normative References . . . . . . . . . . . . . . . . . . . 9
76 11.2. Informative References . . . . . . . . . . . . . . . . . . 9
77 Appendix A. Change Log (to be removed by RFC Editor before
78 publication) . . . . . . . . . . . . . . . . . . . . 10
79 A.1. Since draft-reschke-http-jfv-00 . . . . . . . . . . . . . 10
80 A.2. Since draft-reschke-http-jfv-01 . . . . . . . . . . . . . 10
81 A.3. Since draft-reschke-http-jfv-02 . . . . . . . . . . . . . 10
82 A.4. Since draft-reschke-http-jfv-03 . . . . . . . . . . . . . 11
83 A.5. Since draft-reschke-http-jfv-04 . . . . . . . . . . . . . 11
84 Appendix B. Acknowledgements . . . . . . . . . . . . . . . . . . 11
86 1. Introduction
88 Defining syntax for new HTTP header fields ([RFC7230], Section 3.2)
89 is non-trivial. Among the commonly encountered problems are:
91 o There is no common syntax for complex field values. Several well-
92 known header fields do use a similarly looking syntax, but it is
93 hard to write generic parsing code that will both correctly handle
94 valid field values but also reject invalid ones.
96 o The HTTP message format allows header fields to repeat, so field
97 syntax needs to be designed in a way that these cases are either
98 meaningful, or can be unambiguously detected and rejected.
100 o HTTP/1.1 does not define a character encoding scheme ([RFC6365],
101 Section 2), so header fields are either stuck with US-ASCII
102 ([RFC0020]), or need out-of-band information to decide what
103 encoding scheme is used. Furthermore, APIs usually assume a
104 default encoding scheme in order to map from octet sequences to
105 strings (for instance, [XMLHttpRequest] uses the IDL type
106 "ByteString", effectively resulting in the ISO-8859-1 character
107 encoding scheme [ISO-8859-1] being used).
109 (See Section 8.3.1 of [RFC7231] for a summary of considerations for
110 new header fields.)
112 This specification addresses the issues listed above by defining both
113 a generic JSON-based ([RFC7159]) data model and a concrete wire
114 format that can be used in definitions of new header fields, where
115 the goals were:
117 o to be compatible with header field recombination when fields occur
118 multiple times in a single message (Section 3.2.2 of [RFC7230]),
119 and
121 o not to use any problematic characters in the field value (non-
122 ASCII characters and certain whitespace characters).
124 2. Data Model and Format
126 In HTTP, header fields with the same field name can occur multiple
127 times within a single message (Section 3.2.2 of [RFC7230]). When
128 this happens, recipients are allowed to combine the field values
129 using commas as delimiter. This rule matches nicely JSON's array
130 format (Section 5 of [RFC7159]). Thus, the basic data model used
131 here is the JSON array.
133 Header field definitions that need only a single value can restrict
134 themselves to arrays of length 1, and are encouraged to define error
135 handling in case more values are received (such as "first wins",
136 "last wins", or "abort with fatal error message").
138 JSON arrays are mapped to field values by creating a sequence of
139 serialized member elements, separated by commas and optionally
140 whitespace. This is equivalent to using the full JSON array format,
141 while leaving out the "begin-array" ('[') and "end-array" (']')
142 delimiters.
144 The ABNF character names and classes below are used (copied from
145 [RFC5234], Appendix B.1):
147 CR = %x0D ; carriage return
148 HTAB = %x09 ; horizontal tab
149 LF = %x0A ; line feed
150 SP = %x20 ; space
151 VCHAR = %x21-7E ; visible (printing) characters
153 Characters in JSON strings that are not allowed or discouraged in
154 HTTP header field values -- that is, not in the "VCHAR" definition --
155 need to be represented using JSON's "backslash" escaping mechanism
156 ([RFC7159], Section 7).
158 The control characters CR, LF, and HTAB do not appear inside JSON
159 strings, but can be used outside (line breaks, indentation etc).
160 These characters need to be either stripped or replaced by space
161 characters (ABNF "SP").
163 Formally, using the HTTP specification's ABNF extensions defined in
164 Section 7 of [RFC7230]:
166 json-field-value = #json-field-item
167 json-field-item = JSON-Text
168 ; see [RFC7159], Section 2,
169 ; post-processed so that only VCHAR characters
170 ; are used
172 3. Sender Requirements
174 To map a JSON array to an HTTP header field value, process each array
175 element separately by:
177 1. generating the JSON representation,
179 2. stripping all JSON control characters (CR, HTAB, LF), or
180 replacing them by space ("SP") characters,
182 3. replacing all remaining non-VSPACE characters by the equivalent
183 backslash-escape sequence ([RFC7159], Section 7).
185 The resulting list of strings is transformed into an HTTP field value
186 by combining them using comma (%x2C) plus optional SP as delimiter,
187 and encoding the resulting string into an octet sequence using the
188 US-ASCII character encoding scheme ([RFC0020]).
190 4. Recipient Requirements
192 To map a set of HTTP header field instances to a JSON array:
194 1. combine all header field instances into a single field as per
195 Section 3.2.2 of [RFC7230],
197 2. add a leading begin-array ("[") octet and a trailing end-array
198 ("]") octet, then
200 3. run the resulting octet sequence through a JSON parser.
202 The result of the parsing operation is either an error (in which case
203 the header field values needs to be considered invalid), or a JSON
204 array.
206 5. Using this Format in Header Field Definitions
208 [[anchor5: Explain what a definition of a new header field needs to
209 do precisely to use this format, mention must-ignore extensibiliy]]
211 6. Examples
213 This section shows how some of the existing HTTP header fields would
214 look like if they would use the format defined by this specification.
216 6.1. Content-Length
218 "Content-Length" is defined in Section 3.3.2 of [RFC7230], with the
219 field value's ABNF being:
221 Content-Length = 1*DIGIT
223 So the field value is similar to a JSON number ([RFC7159], Section
224 6).
226 Content-Length is restricted to a single field instance, as it
227 doesn't use the list production (as per Section 3.2.2 of [RFC7230]).
228 However, in practice multiple instances do occur, and the definition
229 of the header field does indeed discuss how to handle these cases.
231 If Content-Length was defined using the JSON format discussed here,
232 the ABNF would be something like:
234 Content-Length = #number
235 ; number: [RFC7159], Section 6
237 ...and the prose definition would:
239 o restrict all numbers to be non-negative integers without
240 fractions, and
242 o require that the array of values is of length 1 (but allow the
243 case where the array is longer, but all members represent the same
244 value)
246 6.2. Content-Disposition
248 Content-Disposition field values, defined in [RFC6266], consist of a
249 "disposition type" (a string), plus multiple parameters, of which at
250 least one ("filename") sometime needs to carry non-ASCII characters.
252 For instance, the first example in Section 5 of [RFC6266]:
254 Attachment; filename=example.html
256 has a disposition type of "Attachment", with filename parameter value
257 "example.html". A JSON representation of this information might be:
259 {
260 "Attachment": {
261 "filename" : "example.html"
262 }
263 }
265 which would translate to a header field value of:
267 { "Attachment": { "filename" : "example.html" } }
269 The third example in Section 5 of [RFC6266] uses a filename parameter
270 containing non-US-ASCII characters:
272 attachment; filename*=UTF-8''%e2%82%ac%20rates
274 Note that in this case, the "filename*" parameter uses the encoding
275 defined in [RFC5987], representing a filename starting with the
276 Unicode character U+20AC (EURO SIGN), followed by " rates". If the
277 definition of Content-Disposition would have used the format proposed
278 here, the workaround involving the "parameter*" syntax would not have
279 been needed at all.
281 The JSON representation of this value could then be:
283 { "attachment": { "filename" : "\u20AC rates" } }
285 6.3. WWW-Authenticate
287 The WWW-Authenticate header field value is defined in Section 4.1 of
288 [RFC7235] as a list of "challenges":
290 WWW-Authenticate = 1#challenge
292 ...where a challenge consists of a scheme with optional parameters:
294 challenge = auth-scheme [ 1*SP ( token68 / #auth-param ) ]
296 An example for a complex header field value given in the definition
297 of the header field is:
299 Newauth realm="apps", type=1, title="Login to \"apps\"",
300 Basic realm="simple"
302 (line break added for readability)
304 A possible JSON representation of this field value would be the array
305 below:
307 [
308 {
309 "Newauth" : {
310 "realm": "apps",
311 "type" : 1,
312 "title" : "Login to \"apps\""
313 }
314 },
315 {
316 "Basic" : {
317 "realm": "simple"
318 }
319 }
320 ]
322 ...which would translate to a header field value of:
324 { "Newauth" : { "realm": "apps", "type" : 1,
325 "title": "Login to \"apps\"" }},
326 { "Basic" : { "realm": "simple"}}
328 7. Discussion
330 This approach uses a default of "JSON array", using implicit array
331 markers. An alternative would be a default of "JSON object". This
332 would simplify the syntax for non-list-typed header fields, but all
333 the benefits of having the same data model for both types of header
334 fields would be gone. A hybrid approach might make sense, as long as
335 it doesn't require any heuristics on the recipient's side.
337 Note: a concrete proposal was made by Kazuho Oku in .
340 [[anchor7: Use of generic libs vs compactness of field values..]]
342 [[anchor8: Mention potential "Key" header field extension ([KEY]).]]
344 8. Deployment Considerations
346 This JSON-based syntax will only apply to newly introduced header
347 fields, thus backwards compatibility is not a problem. That being
348 said, it is conceivable that there is existing code that might trip
349 over double quotes not being used for HTTP's quoted-string syntax
350 (Section 3.2.6 of [RFC7230]).
352 9. Internationalization Considerations
354 In HTTP/1.1, header field values are represented by octet sequences,
355 usually used to transmit ASCII characters, with restrictions on the
356 use of certain control characters, and no associated default
357 character encoding, nor a way to describe it ([RFC7230], Section
358 3.2). HTTP/2 does not change this.
360 This specification maps all characters which can cause problems to
361 JSON escape sequences, thereby solving the HTTP header field
362 internationalization problem.
364 Future specifications of HTTP might change to allow non-ASCII
365 characters natively. In that case, header fields using the syntax
366 defined by this specification would have a simple migration path (by
367 just stopping to require escaping of non-ASCII characters).
369 10. Security Considerations
371 Using JSON-shaped field values is believed to not introduce any new
372 threads beyond those described in Section 12 of [RFC7159], namely the
373 risk of recipients using the wrong tools to parse them.
375 Other than that, any syntax that makes extensions easy can be used to
376 smuggle information through field values; however, this concern is
377 shared with other widely used formats, such as those using parameters
378 in the form of name/value pairs.
380 11. References
382 11.1. Normative References
384 [RFC0020] Cerf, V., "ASCII format for network interchange",
385 STD 80, RFC 20, DOI 10.17487/RFC0020, October 1969,
386 .
388 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for
389 Syntax Specifications: ABNF", STD 68, RFC 5234,
390 DOI 10.17487/RFC5234, January 2008,
391 .
393 [RFC7159] Bray, T., "The JavaScript Object Notation (JSON)
394 Data Interchange Format", RFC 7159, DOI 10.17487/
395 RFC7159, March 2014,
396 .
398 [RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext
399 Transfer Protocol (HTTP/1.1): Message Syntax and
400 Routing", RFC 7230, DOI 10.17487/RFC7230,
401 June 2014,
402 .
404 [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext
405 Transfer Protocol (HTTP/1.1): Semantics and
406 Content", RFC 7231, DOI 10.17487/RFC7231,
407 June 2014,
408 .
410 11.2. Informative References
412 [ISO-8859-1] International Organization for Standardization,
413 "Information technology -- 8-bit single-byte coded
414 graphic character sets -- Part 1: Latin alphabet
415 No. 1", ISO/IEC 8859-1:1998, 1998.
417 [KEY] Fielding, R. and M. Nottingham, "The Key HTTP
418 Response Header Field", draft-ietf-httpbis-key-01
419 (work in progress), March 2016.
421 [RFC5987] Reschke, J., "Character Set and Language Encoding
422 for Hypertext Transfer Protocol (HTTP) Header Field
423 Parameters", RFC 5987, DOI 10.17487/RFC5987,
424 August 2010,
425 .
427 [RFC6266] Reschke, J., "Use of the Content-Disposition Header
428 Field in the Hypertext Transfer Protocol (HTTP)",
429 RFC 6266, DOI 10.17487/RFC6266, June 2011,
430 .
432 [RFC6365] Hoffman, P. and J. Klensin, "Terminology Used in
433 Internationalization in the IETF", BCP 166,
434 RFC 6365, DOI 10.17487/RFC6365, September 2011,
435 .
437 [RFC7235] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext
438 Transfer Protocol (HTTP/1.1): Authentication",
439 RFC 7235, DOI 10.17487/RFC7235, June 2014,
440 .
442 [XMLHttpRequest] van Kesteren, A., Aubourg, J., Song, J., and H.
443 Steen, "XMLHttpRequest Level 1", W3C Working
444 Draft WD-XMLHttpRequest-20140130, January 2014, .
448 Latest version available at
449 .
451 Appendix A. Change Log (to be removed by RFC Editor before publication)
453 A.1. Since draft-reschke-http-jfv-00
455 Editorial fixes + working on the TODOs.
457 A.2. Since draft-reschke-http-jfv-01
459 Mention slightly increased risk of smuggling information in header
460 field values.
462 A.3. Since draft-reschke-http-jfv-02
464 Mention Kazuho Oku's proposal for abbreviated forms.
466 Added a bit of text about the motivation for a concrete JSON subset
467 (ack Cory Benfield).
469 Expand I18N section.
471 A.4. Since draft-reschke-http-jfv-03
473 Mention relation to KEY header field.
475 A.5. Since draft-reschke-http-jfv-04
477 Change to HTTP Working Group draft.
479 Appendix B. Acknowledgements
481 Thanks go to the Hypertext Transfer Protocol Working Group
482 participants.
484 Author's Address
486 Julian F. Reschke
487 greenbytes GmbH
488 Hafenweg 16
489 Muenster, NW 48155
490 Germany
492 EMail: julian.reschke@greenbytes.de
493 URI: http://greenbytes.de/tech/webdav/