RE: Design Issue: Life-cycle of a Stream

Mike Bishop <Michael.Bishop@microsoft.com> Wed, 01 May 2013 18:10 UTC

Return-Path: <ietf-http-wg-request@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 877B121F9AC6 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Wed, 1 May 2013 11:10:38 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.44
X-Spam-Level:
X-Spam-Status: No, score=-6.44 tagged_above=-999 required=5 tests=[AWL=-1.026, BAYES_00=-2.599, HTML_MESSAGE=0.001, MIME_8BIT_HEADER=0.3, MIME_BASE64_TEXT=1.753, RCVD_IN_DNSWL_HI=-8, UNRESOLVED_TEMPLATE=3.132]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LUvS3LX8LBEV for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Wed, 1 May 2013 11:10:31 -0700 (PDT)
Received: from frink.w3.org (frink.w3.org [128.30.52.56]) by ietfa.amsl.com (Postfix) with ESMTP id 0E3A921F9AB9 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Wed, 1 May 2013 11:10:31 -0700 (PDT)
Received: from lists by frink.w3.org with local (Exim 4.72) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1UXbSm-0004p3-Bk for ietf-http-wg-dist@listhub.w3.org; Wed, 01 May 2013 18:09:08 +0000
Resent-Date: Wed, 01 May 2013 18:09:08 +0000
Resent-Message-Id: <E1UXbSm-0004p3-Bk@frink.w3.org>
Received: from lisa.w3.org ([128.30.52.41]) by frink.w3.org with esmtp (Exim 4.72) (envelope-from <Michael.Bishop@microsoft.com>) id 1UXbSa-0004oC-24 for ietf-http-wg@listhub.w3.org; Wed, 01 May 2013 18:08:56 +0000
Received: from mail-bn1lp0157.outbound.protection.outlook.com ([207.46.163.157] helo=na01-bn1-obe.outbound.protection.outlook.com) by lisa.w3.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from <Michael.Bishop@microsoft.com>) id 1UXbSY-0000Hs-Mx for ietf-http-wg@w3.org; Wed, 01 May 2013 18:08:56 +0000
Received: from BN1BFFO11FD010.protection.gbl (10.58.52.201) by BN1AFFO11HUB021.protection.gbl (10.58.52.131) with Microsoft SMTP Server (TLS) id 15.0.687.1; Wed, 1 May 2013 18:08:27 +0000
Received: from TK5EX14HUBC106.redmond.corp.microsoft.com (131.107.125.37) by BN1BFFO11FD010.mail.protection.outlook.com (10.58.53.70) with Microsoft SMTP Server (TLS) id 15.0.687.1 via Frontend Transport; Wed, 1 May 2013 18:08:27 +0000
Received: from va3outboundpool.messaging.microsoft.com (157.54.51.114) by mail.microsoft.com (157.54.80.61) with Microsoft SMTP Server (TLS) id 14.2.318.3; Wed, 1 May 2013 18:08:21 +0000
Received: from mail161-va3-R.bigfish.com (10.7.14.226) by VA3EHSOBE012.bigfish.com (10.7.40.62) with Microsoft SMTP Server id 14.1.225.23; Wed, 1 May 2013 18:05:08 +0000
Received: from mail161-va3 (localhost [127.0.0.1]) by mail161-va3-R.bigfish.com (Postfix) with ESMTP id 6B11C2A012C for <ietf-http-wg@w3.org.FOPE.CONNECTOR.OVERRIDE>; Wed, 1 May 2013 18:05:08 +0000 (UTC)
X-Forefront-Antispam-Report-Untrusted: CIP:157.56.240.21; KIP:(null); UIP:(null); (null); H:BL2PRD0310HT004.namprd03.prod.outlook.com; R:internal; EFV:INT
X-SpamScore: -1
X-BigFish: PS-1(zz98dI9371Ic85bh148cI1506Jzz1f42h1fc6h1ee6h1de0h1fdah1202h1e76h1d1ah1d2ahzz18c58eh17326ah18c673h8275bh8275dhz31h2a8h668h839hd24hf0ah1288h12a5h12bdh137ah1441h1504h1537h153bh162dh1631h1758h18e1h1946h19b5h1ad9h1b0ah1bceh1d07h1d0ch1d2eh17ej9a9j1155h)
Received-SPF: softfail (mail161-va3: transitioning domain of microsoft.com does not designate 157.56.240.21 as permitted sender) client-ip=157.56.240.21; envelope-from=Michael.Bishop@microsoft.com; helo=BL2PRD0310HT004.namprd03.prod.outlook.com ; .outlook.com ;
X-Forefront-Antispam-Report-Untrusted: SFV:SKI; SFS:; DIR:OUT; SFP:; SCL:-1; SRVR:BY2PR03MB027; H:BY2PR03MB025.namprd03.prod.outlook.com; LANG:en;
Received: from mail161-va3 (localhost.localdomain [127.0.0.1]) by mail161-va3 (MessageSwitch) id 1367431505310178_6082; Wed, 1 May 2013 18:05:05 +0000 (UTC)
Received: from VA3EHSMHS031.bigfish.com (unknown [10.7.14.233]) by mail161-va3.bigfish.com (Postfix) with ESMTP id 42351C007A; Wed, 1 May 2013 18:05:05 +0000 (UTC)
Received: from BL2PRD0310HT004.namprd03.prod.outlook.com (157.56.240.21) by VA3EHSMHS031.bigfish.com (10.7.99.41) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 1 May 2013 18:04:50 +0000
Received: from BY2PR03MB027.namprd03.prod.outlook.com (10.255.240.41) by BL2PRD0310HT004.namprd03.prod.outlook.com (10.255.97.39) with Microsoft SMTP Server (TLS) id 14.16.305.3; Wed, 1 May 2013 18:04:49 +0000
Received: from BY2PR03MB025.namprd03.prod.outlook.com (10.255.240.39) by BY2PR03MB027.namprd03.prod.outlook.com (10.255.240.41) with Microsoft SMTP Server (TLS) id 15.0.670.13; Wed, 1 May 2013 18:04:46 +0000
Received: from BY2PR03MB025.namprd03.prod.outlook.com ([169.254.9.30]) by BY2PR03MB025.namprd03.prod.outlook.com ([169.254.9.68]) with mapi id 15.00.0670.000; Wed, 1 May 2013 18:04:46 +0000
From: Mike Bishop <Michael.Bishop@microsoft.com>
To: =?gb2312?B?V2lsbGlhbSBDaGFuICizwtbHsv0p?= <willchan@chromium.org>, "James M Snell" <jasnell@gmail.com>
CC: "ietf-http-wg@w3.org" <ietf-http-wg@w3.org>
Thread-Topic: Design Issue: Life-cycle of a Stream
Thread-Index: AQHORo5eysIRINi3+E2wP0ZG63NlVZjwl7UAgAADjvA=
Date: Wed, 1 May 2013 18:04:45 +0000
Message-ID: <43b4453b71644de69f2c064df2379920@BY2PR03MB025.namprd03.prod.outlook.com>
References: <CABP7Rbd08=A6FGA_Huydcx59MWjd7GgBsZ-hcQfAB4mt3d72yQ@mail.gmail.com> <CAA4WUYiDLsc8VLiwfLbBAFk+Gc3MsZhxfYJ2qJUHZ06UwtM8Fw@mail.gmail.com>
In-Reply-To: <CAA4WUYiDLsc8VLiwfLbBAFk+Gc3MsZhxfYJ2qJUHZ06UwtM8Fw@mail.gmail.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originating-ip: [2001:4898:1b:4:e830:166:821:28f2]
Content-Type: multipart/alternative; boundary="_000_43b4453b71644de69f2c064df2379920BY2PR03MB025namprd03pro_"
MIME-Version: 1.0
X-OrganizationHeadersPreserved: BY2PR03MB027.namprd03.prod.outlook.com
X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn%
X-FOPE-CONNECTOR: Id%59$Dn%W3.ORG$RO%2$TLS%6$FQDN%corpf5vips-237160.customer.frontbridge.com$TlsDn%
X-FOPE-CONNECTOR: Id%59$Dn%GMAIL.COM$RO%2$TLS%6$FQDN%corpf5vips-237160.customer.frontbridge.com$TlsDn%
X-FOPE-CONNECTOR: Id%59$Dn%CHROMIUM.ORG$RO%2$TLS%6$FQDN%corpf5vips-237160.customer.frontbridge.com$TlsDn%
X-CrossPremisesHeadersPromoted: TK5EX14HUBC106.redmond.corp.microsoft.com
X-CrossPremisesHeadersFiltered: TK5EX14HUBC106.redmond.corp.microsoft.com
X-Forefront-Antispam-Report: CIP:131.107.125.37; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(52604004)(189002)(199002)(24454001)(53824001)(377454001)(15202345002)(76482001)(4396001)(16676001)(49866001)(74706001)(47736001)(50986001)(47976001)(6806003)(31966008)(74316001)(47446002)(16234385002)(74662001)(77982001)(74502001)(54356001)(56776001)(54316002)(51856001)(80022001)(69226001)(20776003)(512914004)(33646001)(74366001)(53806001)(65816001)(71186001)(79102001)(16236675002)(59766001)(81542001)(63696002)(56816002)(81342001)(46102001)(24736002)(3826001); DIR:OUT; SFP:; SCL:1; SRVR:BN1AFFO11HUB021; H:TK5EX14HUBC106.redmond.corp.microsoft.com; RD:InfoDomainNonexistent; MX:1; A:1; LANG:en;
X-OriginatorOrg: microsoft.onmicrosoft.com
X-Forefront-PRVS: 08331F819E
Received-SPF: pass client-ip=207.46.163.157; envelope-from=Michael.Bishop@microsoft.com; helo=na01-bn1-obe.outbound.protection.outlook.com
X-W3C-Hub-Spam-Status: No, score=-2.5
X-W3C-Hub-Spam-Report: AWL=-3.182, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, UNRESOLVED_TEMPLATE=0.716
X-W3C-Scan-Sig: lisa.w3.org 1UXbSY-0000Hs-Mx 7a47d45873063a5369fc0b70b5a76856
X-Original-To: ietf-http-wg@w3.org
Subject: RE: Design Issue: Life-cycle of a Stream
Archived-At: <http://www.w3.org/mid/43b4453b71644de69f2c064df2379920@BY2PR03MB025.namprd03.prod.outlook.com>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/17768
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>

#5 vs. #1 raises a potential issue:  A stream is opened by sending a HEADERS or HEADERS+PRIORITY, but none of the states in #5 match a stream which hasn’t been opened yet.  To say that it’s closed to begin with suggests that a stream which has been half-closed by both sides could be re-opened later, which I don’t think any of us have suggested is a healthy option.

I’m inclined to say that there is an uninitialized state in which a stream has not been opened yet.  Receipt of HEADERS/HEADERS+PRIORITY (or any frame, if we want to minimize the HTTP semantics in the framing layer) moves the stream from uninitialized to open.  Receipt of a PUSH_PROMISE referencing the stream ID moves the client from uninitialized to half-closed, since the client’s side of the exchange is inferred from what’s already sent.

I agree with Will on the 9-11 options.  Each stream lives or dies on its own, and we should keep their lifecycles as distinct as possible.  They need to be linked, because you have to not have discarded the parent stream’s state in order to infer the state for the push stream; once that state has been copied, I think it should be a fully distinct stream.

(Though #9 might need to be revisited if we allow pushed streams to have priority in a future discussion.)

From: willchan@google.com [mailto:willchan@google.com] On Behalf Of William Chan (???)
Sent: Wednesday, May 1, 2013 10:36 AM
To: James M Snell
Cc: ietf-http-wg@w3.org
Subject: Re: Design Issue: Life-cycle of a Stream

Thanks for sending this email. This is great. I'll chime in with my personal interpretations.

On Wed, May 1, 2013 at 2:03 PM, James M Snell <jasnell@gmail.com<mailto:jasnell@gmail.com>> wrote:
The current spec is rather vague on the complete life-cycle of a
stream within a session. Aside from discussing how the Mommy Endpoint
and the Daddy Endpoint get together, we ought to take just a bit of
time to make sure we're all on the same page...

In a separate thread, several of us discussed stream creation...
specifically, how is a stream initiated. Let's see if we can formalize
the process and the language. I've written the following out as
statements, if you disagree with the statement or see it a different
way, lemme know! Some of this is obvious and well established, I'm
documenting it here just to make sure we have the complete picture
captured. I've marked the items that appear to me to be the most
controversial with an asterisk.

1. Streams are initialized or opened by sending a HEADERS or
HEADERS+PRIORITY frame that uses a previously unused stream
identifier.

2. Only HEADERS and HEADERS+PRIORITY frames are used to open a stream.

3. PUSH_PROMISE frames reserve a stream identifier but do not open the stream.

4. Promised streams are only opened by sending a subsequent HEADERS or
HEADERS+PRIORITY frame that uses the reserved stream identifier.

5. All streams are either fully open, half-closed by the client,
half-closed by the server, or fully closed.

6. All promised streams are associated with an originating "parent" stream.

For HTTP/2 I think this totally makes sense and this is the right interpretation. Again, if we assume the framing layer is separate from HTTP/2 usage, then this might not be good to require.


7. A stream is half-closed by sending a frame with the FINAL bit set.

8. A stream becomes fully-closed when either: a) both endpoints send
frames with the FINAL bit set or b) either endpoint sends an RST_FRAME
with that streams identifier.

9*. Promised streams are automatically half-closed for the recipient.
That is, when the server sends a PUSH_PROMISE to a client, that
streams becomes automatically half-closed for the client. The only
frame the client can send back to the server for that stream are
RST_STREAM frames.

I think we agreed on this interpretation in the last email thread you raised on PUSH_PROMISE.


  -- or --

9*. Promised streams are handled just like regular streams. The server
opens the stream and half-closes. The stream does not fully close
until either the client half-closes it or a RST_STREAM frame is sent
for that stream.

10*. Sending an RST_FRAME for a parent stream fully closes that stream
as well as all associated promised streams.

  -- or --

10*. Sending an RST_FRAME for a parent stream only closes that stream
and has no affect on associated promised streams.

I forget if we settled this issue or not. But I'm inclined to prefer your second interpretation here. I'd rather explicitly reset streams.


11*. Fully closing a parent stream using symmetric half-closes will
fully close all associated promised streams.

  -- or --

11*. Fully closing a parent stream using symmetric half-closes has no
affect on associated promised streams.

The latter. I believe the spec only says we have to promise the streams before the parent stream closes. We don't have to even open the streams yet. This is probably ideal since the parent stream is likely the main document, and the main document is likely to contain the most important data. One might say just send all the data and delay the sending of a 0-byte DATA frame with the FINAL flag set, but I see no reason to require that. Speaking as an implementer, it's easier for the browser to receive the FINAL flag ASAP (there are some implementation complications with multiple readers and single writer, where multiple "readers" are requesting a resource at the same URL, and are sharing the same response...we stream the response to a single reader and only when we know it to be complete do we stream to all other readers. don't ask me why, it's complicated and relates to our cache implementation).


12. Half or fully closing a promised stream has no impact on the
parent stream or any associated sibling promised streams.

Ok, so that covers the lifecycle.. let's talk about processing.. this
is largely a reiteration of my previous note on this but I want to
make sure I've hit all the major points in how this is categorized.

I don't really want to start calling this Tier Number. I call things by the relevant layer. Everyone else at the in person meetings has done the same. I know jpinner@ has organized his code accordingly to his view of the layers. I'd like us to standardize terminology on that.


Tier 1: Includes the following...

A. Reception and basic parsing of frames. "Basic parsing" here means
looking at the header bytes to determine the frame type, making note
of the flags, frame size and stream identifier, and performing any
necessary header block decompression and state management.

B. Handling of all session frames (stream id #0). This means that
upgrade negotiation, SETTINGS, PING, flow control and session level
error handling are all Tier 1 processes.

C. Basic lifecycle handling of stream frames. This includes
determination of whether a stream is open or closed, whether or not
additional frames are allowed for a stream, validation of proper
stream id use, reservation of stream id's with push_promise, and
handling of the FINAL flag.

Tier 2: Includes the following...

A. Frame-type specific processing. Validation and handling of frame
payloads and frame-specific flags, not including header block
processing (which is tier 1)

B. Additional stream-level error handling not related to stream-lifecycle

Tier 3: Includes all application-level handling (HTTP Semantics)

So, when we say things like "an endpoint must be prepared to continue
receiving frames on a closed stream", we mean to say that "an endpoint
must be prepared to do tier 1 processing on all frames, even those
sent for closed streams."

Please weigh in on whatever items y'all feel are controversial. I'll
work up proposed spec edits based on whatever feedback is received.

- James