Re: JSON headers

Willy Tarreau <w@1wt.eu> Tue, 12 July 2016 04:18 UTC

Return-Path: <ietf-http-wg-request+bounce-httpbisa-archive-bis2juki=lists.ie@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id B61EC128E19 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Mon, 11 Jul 2016 21:18:44 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -8.208
X-Spam-Level:
X-Spam-Status: No, score=-8.208 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.287, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HsVyIzV6l6S4 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Mon, 11 Jul 2016 21:18:43 -0700 (PDT)
Received: from frink.w3.org (frink.w3.org [128.30.52.56]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 9F7D3128B44 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Mon, 11 Jul 2016 21:18:43 -0700 (PDT)
Received: from lists by frink.w3.org with local (Exim 4.80) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1bMp5U-0002ug-6M for ietf-http-wg-dist@listhub.w3.org; Tue, 12 Jul 2016 04:14:24 +0000
Resent-Date: Tue, 12 Jul 2016 04:14:24 +0000
Resent-Message-Id: <E1bMp5U-0002ug-6M@frink.w3.org>
Received: from lisa.w3.org ([128.30.52.41]) by frink.w3.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from <w@1wt.eu>) id 1bMp5Q-0002tm-GI for ietf-http-wg@listhub.w3.org; Tue, 12 Jul 2016 04:14:20 +0000
Received: from wtarreau.pck.nerim.net ([62.212.114.60] helo=1wt.eu) by lisa.w3.org with esmtp (Exim 4.80) (envelope-from <w@1wt.eu>) id 1bMp5O-0000ZK-GC for ietf-http-wg@w3.org; Tue, 12 Jul 2016 04:14:19 +0000
Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id u6C4AeoP010457; Tue, 12 Jul 2016 06:10:40 +0200
Date: Tue, 12 Jul 2016 06:10:40 +0200
From: Willy Tarreau <w@1wt.eu>
To: Yanick Rochon <yanick.rochon@gmail.com>
Cc: Julian Reschke <julian.reschke@gmx.de>, Poul-Henning Kamp <phk@phk.freebsd.dk>, Phil Hunt <phil.hunt@oracle.com>, HTTP Working Group <ietf-http-wg@w3.org>
Message-ID: <20160712041040.GE10172@1wt.eu>
References: <9221.1468245597@critter.freebsd.dk> <aa9cee9c-d8e3-17ba-9fcd-e327575cd5a8@gmx.de> <9801.1468259070@critter.freebsd.dk> <15d27f23-6b51-1e8e-3f10-194c80570424@gmx.de> <20160711190107.GB9542@1wt.eu> <0e467573-4f68-80a5-14a4-5a63b41ac4d4@gmx.de> <20160711192515.GA9614@1wt.eu> <CAB0No9kgPJqMZQ2=qpMw4yh7Tq-1V+nkuagrN71HTTeXYpJ9kA@mail.gmail.com> <20160712032237.GA10172@1wt.eu> <CAB0No9mB-yAoPZqp7AE_HYdVSPicKh2xed4m=Dxfz7vrMD+sjg@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <CAB0No9mB-yAoPZqp7AE_HYdVSPicKh2xed4m=Dxfz7vrMD+sjg@mail.gmail.com>
User-Agent: Mutt/1.6.0 (2016-04-01)
Received-SPF: pass client-ip=62.212.114.60; envelope-from=w@1wt.eu; helo=1wt.eu
X-W3C-Hub-Spam-Status: No, score=-5.5
X-W3C-Hub-Spam-Report: AWL=-0.573, BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, W3C_AA=-1, W3C_IRA=-1, W3C_WL=-1
X-W3C-Scan-Sig: lisa.w3.org 1bMp5O-0000ZK-GC 73f664c2d2b4209cf677edc18852b5c9
X-Original-To: ietf-http-wg@w3.org
Subject: Re: JSON headers
Archived-At: <http://www.w3.org/mid/20160712041040.GE10172@1wt.eu>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/31914
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <http://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

On Mon, Jul 11, 2016 at 11:58:03PM -0400, Yanick Rochon wrote:
> On 11 July 2016 at 23:22, Willy Tarreau <w@1wt.eu> wrote:
> 
> > On Mon, Jul 11, 2016 at 03:47:32PM -0400, Yanick Rochon wrote:
> > > On 11 July 2016 at 15:25, Willy Tarreau <w@1wt.eu> wrote:
> > >
> > For me it means it sent two values for the Accept header defined as a list,
> > the first one being "appliation/xml...", and the second one
> > "text/plain...".
> > ... *snip*
> 
> 
> > Since it seams easy to me I'm having an issue understanding the deeper
> > problem and am pretty sure I missed something :-/
> >
> 
> Well, first arrays are enclosed in square brackets, nor curly ones :)

OK thanks :-)

> Second, I am not talking about the format per se, but about possible
> headers being sent as described (i.e. with duplicated keys). Of course,
> JavaScript objects cannot have duplicate keys, however JSON representations
> as strings are not bound to this limitation, and may very well be sent as
> such. (Also, even if it is expected that every values must be an array,
> JSON allows a few more possible values to be set, like strings, etc.) The
> point is that, { "Accept": "...", "Accept": [ "..." ] } is a valid JSON
> object, yet is (or should be) invalid as header value. What then?

But precisely my point is to declare that all JSON headers are lists (or
arrays apparently in JSON). Thus you just send array *elements* and the
recipient appends them to the array. So you don't have the object above,
you just have { "Accept": [ "..." ] }. This removes the possibility of
duplicate keys and keeps the ability to have multiple values for a header.
And it also allows to stop at the first value when you expect to use only
one value for a header that you don't intend to check for uniqueness.

Willy