Re: JSON headers

Willy Tarreau <w@1wt.eu> Sun, 10 July 2016 18:30 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 C1A0712B05F for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Sun, 10 Jul 2016 11:30:57 -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 R_urYDDo93B4 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Sun, 10 Jul 2016 11:30:56 -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 0E2FF12B041 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Sun, 10 Jul 2016 11:30:55 -0700 (PDT)
Received: from lists by frink.w3.org with local (Exim 4.80) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1bMJRQ-0003kq-Sk for ietf-http-wg-dist@listhub.w3.org; Sun, 10 Jul 2016 18:26:56 +0000
Resent-Date: Sun, 10 Jul 2016 18:26:56 +0000
Resent-Message-Id: <E1bMJRQ-0003kq-Sk@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 1bMJRN-0003jj-2n for ietf-http-wg@listhub.w3.org; Sun, 10 Jul 2016 18:26:53 +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 1bMJRL-0006OY-DK for ietf-http-wg@w3.org; Sun, 10 Jul 2016 18:26:52 +0000
Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id u6AIQLvu007873; Sun, 10 Jul 2016 20:26:21 +0200
Date: Sun, 10 Jul 2016 20:26:21 +0200
From: Willy Tarreau <w@1wt.eu>
To: Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc: Julian Reschke <julian.reschke@gmx.de>, Phil Hunt <phil.hunt@oracle.com>, HTTP Working Group <ietf-http-wg@w3.org>
Message-ID: <20160710182621.GA7848@1wt.eu>
References: <74180.1468000149@critter.freebsd.dk> <A17D3EFD-A935-4971-BCF6-DC9D38302CAD@oracle.com> <564a72e8-b9d3-1f9c-5982-48f2b07272e5@greenbytes.de> <3924.1468137899@critter.freebsd.dk> <683f5f58-6046-d9fb-cc75-d0ab3890ce23@greenbytes.de> <4105.1468141779@critter.freebsd.dk> <5cdf0fa8-063c-7eaa-a9e3-fb6db7417254@gmx.de> <4213.1468143913@critter.freebsd.dk> <94e4a5c2-3465-fef3-6221-d9f4fcccb5fa@gmx.de> <4324.1468145426@critter.freebsd.dk>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <4324.1468145426@critter.freebsd.dk>
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.575, 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 1bMJRL-0006OY-DK 53cd1b5e759f4cd7cd5d8ddfbb26b265
X-Original-To: ietf-http-wg@w3.org
Subject: Re: JSON headers
Archived-At: <http://www.w3.org/mid/20160710182621.GA7848@1wt.eu>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/31864
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 Sun, Jul 10, 2016 at 10:10:26AM +0000, Poul-Henning Kamp wrote:
> --------
> In message <94e4a5c2-3465-fef3-6221-d9f4fcccb5fa@gmx.de>, Julian Reschke writes
> :
> 
> >But right now the spec *is* written to use the list construct, and I 
> >believe that's a good thing, as it's IMHO better to consider multiple 
> >instances as legal, and require the definition of the header field to 
> >deal with it.
> 
> I think it is a bad thing.
> 
> It prevents streaming processing of headers, since you never know
> when you have the full picture for a particular header, until you've
> received them all and seen that there are no more instances.
> 
> It means also means that either you have to rewrite the headers, or
> all your code needs to do the brute-force collection scan and handle
> an array of headers for further processing.  Both of which is wasteful
> in terms of CPU and memory.
> 
> I see no advantages that come even close to compensating for those
> disadvantages, but if I have overlooked something, please enlighten me...

I have a different appreciation on this matter. We've seen over the year
that people were introducing headers for a specific usage and were pretty
sure these ones ought to be unique. But in the end they were not. The best
example of this is X-Forwarded-For. Each reverse-proxy adds it. Most
implementations never used to consider it as a list as nothing was clear
regarding this, and initial designs were simply "setting" the header.
Some naive designs just used to append it after all headers. Some would
replace the CR LF CR LF with "CR LF xff CR LF CR LF". Each of them was
pretty sure to do the right thing regarding a supposedly unique header.

But they were wrong. In fact they were doing the right thing for a list
and not the right thing for a single header. And that's fortunate because
now we all know that seeing chained XFF is something very common when you
start to stack a load balancer and a cache for example.

All this to say we cannot decide in advance how headers will be produced
nor what they will mean. But that's not a problem. The problem is with
how the headers are interpreted. That's what we need to work on. I'd
instead suggest that all new headers are lists, that they will support
multiple occurrences, and that for all those where it's not obvious what
multiple occurrences will mean, we explicitly mention that only the first
one should be used. We can then have a predictible behaviour because the
first header found allows us to take a routing decision on the fly,
unless we know something specific regarding this one. And this way,
appending new values (a la XFF) will have no unexpected side effect on
those not willing to consume them.

Willy