H2 vs responses which should not carry any payload

Willy Tarreau <w@1wt.eu> Fri, 23 October 2020 04:57 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 52B9E3A11C3 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Thu, 22 Oct 2020 21:57:31 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.649
X-Spam-Level:
X-Spam-Status: No, score=-2.649 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 FDXR7jhNGaHg for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Thu, 22 Oct 2020 21:57:29 -0700 (PDT)
Received: from lyra.w3.org (lyra.w3.org [128.30.52.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 48CB33A11C2 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Thu, 22 Oct 2020 21:57:29 -0700 (PDT)
Received: from lists by lyra.w3.org with local (Exim 4.92) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1kVp6D-0006fq-Dj for ietf-http-wg-dist@listhub.w3.org; Fri, 23 Oct 2020 04:54:45 +0000
Resent-Date: Fri, 23 Oct 2020 04:54:45 +0000
Resent-Message-Id: <E1kVp6D-0006fq-Dj@lyra.w3.org>
Received: from titan.w3.org ([128.30.52.76]) by lyra.w3.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <w@1wt.eu>) id 1kVp6A-0006f4-6p for ietf-http-wg@listhub.w3.org; Fri, 23 Oct 2020 04:54:42 +0000
Received: from wtarreau.pck.nerim.net ([62.212.114.60] helo=1wt.eu) by titan.w3.org with esmtp (Exim 4.92) (envelope-from <w@1wt.eu>) id 1kVp67-0001YO-Ru for ietf-http-wg@w3.org; Fri, 23 Oct 2020 04:54:41 +0000
Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 09N4sQJP005072 for ietf-http-wg@w3.org; Fri, 23 Oct 2020 06:54:26 +0200
Date: Fri, 23 Oct 2020 06:54:26 +0200
From: Willy Tarreau <w@1wt.eu>
To: HTTP Working Group <ietf-http-wg@w3.org>
Message-ID: <20201023045426.GB4941@1wt.eu>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
User-Agent: Mutt/1.6.1 (2016-04-27)
Received-SPF: pass client-ip=62.212.114.60; envelope-from=w@1wt.eu; helo=1wt.eu
X-W3C-Hub-Spam-Status: No, score=-7.9
X-W3C-Hub-Spam-Report: BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, W3C_AA=-1, W3C_IRA=-1, W3C_IRR=-3, W3C_WL=-1
X-W3C-Scan-Sig: titan.w3.org 1kVp67-0001YO-Ru 279fed3a04218e74c5583bf27f5a0e59
X-Original-To: ietf-http-wg@w3.org
Subject: H2 vs responses which should not carry any payload
Archived-At: <https://www.w3.org/mid/20201023045426.GB4941@1wt.eu>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/38109
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: <https://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

Hi all,

we've recently faced a stupid case in haproxy with H2 and I realized that
I didn't find the good response in the spec.

What we've seen is that a client sends a HEAD request, which we forward
to the server. In response the server returns an error with some payload
(possibly a typical pre-made error page that doesn't care about the method),
and haproxy forwards both the HEADERS and DATA frames to the client, then
the client complains about protocol violations (I don't know yet what the
client is for now but I don't think it's important).

We were wondering where we ought to trim the payload in this case (and
for 204/304 as well), whether we ought to do this while reading the
response from the server or when sending the response do the client, and I
figured that nowhere at all in 7540 is mentioned anything about 204/304/HEAD
and that made me start to wonder if adjusting this at the H2 level is the
right solution, and if we ought to do anything about it or not (since
after all maybe everyone is right in this whole chain).

We all know that 204/304/HEAD are between transport and semantics because
for H1 these directly affect the parsing. From this perspective it would make
sense to consider that H2 should drop these. But if we consider semantics
only, it also makes sense to consider that H2 should let everything pass
through.

And even then, do all implementations accept, say, a HEADERS frame with
no ES flag in response to a HEAD request, followed by an empty DATA frame
carrying the ES flag ? At the semantic level it's OK since there's no
payload, but I can understand how some could find it annoying to wait
for DATA frames when no payload is expected (it's our case as well as
part of the possible fixes for this).

For those who want a bit more details, internally we're not directly
forwarding frames but transcoding these into a version-agnostic HTTP
representation that allows us to have either H1 or H2 on any side. This
internal version carries the semantics. If we decide that H2 has nothing
to do with this, we can decide to perform the filtering at the semantics
layer, while knowing that when it comes to H1 it still has to take these
special cases for the messaging anyway. It even makes me suspect that
the contraints are double, in that HEAD/204/304 ought to see no response
payload at the semantic layer, and that H1 is a special case in that it
cannot accept that either at the transport layer to respect the messaging
and that it's not a problem if it duplicates that check.

I'm interested in any opinion on this subject (or any pointers to anything
I could have missed).

Thanks!
Willy