RE: Design Issue: Life-cycle of a Stream

Mike Bishop <> Wed, 01 May 2013 18:10 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 877B121F9AC6 for <>; Wed, 1 May 2013 11:10:38 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -6.44
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 ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id LUvS3LX8LBEV for <>; Wed, 1 May 2013 11:10:31 -0700 (PDT)
Received: from ( []) by (Postfix) with ESMTP id 0E3A921F9AB9 for <>; Wed, 1 May 2013 11:10:31 -0700 (PDT)
Received: from lists by with local (Exim 4.72) (envelope-from <>) id 1UXbSm-0004p3-Bk for; Wed, 01 May 2013 18:09:08 +0000
Resent-Date: Wed, 01 May 2013 18:09:08 +0000
Resent-Message-Id: <>
Received: from ([]) by with esmtp (Exim 4.72) (envelope-from <>) id 1UXbSa-0004oC-24 for; Wed, 01 May 2013 18:08:56 +0000
Received: from ([] by with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from <>) id 1UXbSY-0000Hs-Mx for; Wed, 01 May 2013 18:08:56 +0000
Received: from ( by ( with Microsoft SMTP Server (TLS) id 15.0.687.1; Wed, 1 May 2013 18:08:27 +0000
Received: from ( by ( with Microsoft SMTP Server (TLS) id 15.0.687.1 via Frontend Transport; Wed, 1 May 2013 18:08:27 +0000
Received: from ( by ( with Microsoft SMTP Server (TLS) id 14.2.318.3; Wed, 1 May 2013 18:08:21 +0000
Received: from ( by ( with Microsoft SMTP Server id; Wed, 1 May 2013 18:05:08 +0000
Received: from mail161-va3 (localhost []) by (Postfix) with ESMTP id 6B11C2A012C for <>; Wed, 1 May 2013 18:05:08 +0000 (UTC)
X-Forefront-Antispam-Report-Untrusted: CIP:; KIP:(null); UIP:(null); (null);; R:internal; EFV:INT
X-SpamScore: -1
X-BigFish: PS-1(zz98dI9371Ic85bh148cI1506Jzz1f42h1fc6h1ee6h1de0h1fdah1202h1e76h1d1ah1d2ahzz18c58eh17326ah18c673h8275bh8275dhz31h2a8h668h839hd24hf0ah1288h12a5h12bdh137ah1441h1504h1537h153bh162dh1631h1758h18e1h1946h19b5h1ad9h1b0ah1bceh1d07h1d0ch1d2eh17ej9a9j1155h)
Received-SPF: softfail (mail161-va3: transitioning domain of does not designate as permitted sender) client-ip=;; ; ;
X-Forefront-Antispam-Report-Untrusted: SFV:SKI; SFS:; DIR:OUT; SFP:; SCL:-1; SRVR:BY2PR03MB027;; LANG:en;
Received: from mail161-va3 (localhost.localdomain []) by mail161-va3 (MessageSwitch) id 1367431505310178_6082; Wed, 1 May 2013 18:05:05 +0000 (UTC)
Received: from (unknown []) by (Postfix) with ESMTP id 42351C007A; Wed, 1 May 2013 18:05:05 +0000 (UTC)
Received: from ( by ( with Microsoft SMTP Server (TLS) id; Wed, 1 May 2013 18:04:50 +0000
Received: from ( by ( with Microsoft SMTP Server (TLS) id 14.16.305.3; Wed, 1 May 2013 18:04:49 +0000
Received: from ( by ( with Microsoft SMTP Server (TLS) id 15.0.670.13; Wed, 1 May 2013 18:04:46 +0000
Received: from ([]) by ([]) with mapi id 15.00.0670.000; Wed, 1 May 2013 18:04:46 +0000
From: Mike Bishop <>
To: =?gb2312?B?V2lsbGlhbSBDaGFuICizwtbHsv0p?= <>, "James M Snell" <>
CC: "" <>
Thread-Topic: Design Issue: Life-cycle of a Stream
Thread-Index: AQHORo5eysIRINi3+E2wP0ZG63NlVZjwl7UAgAADjvA=
Date: Wed, 1 May 2013 18:04:45 +0000
Message-ID: <>
References: <> <>
In-Reply-To: <>
Accept-Language: en-US
Content-Language: en-US
x-originating-ip: [2001:4898:1b:4:e830:166:821:28f2]
Content-Type: multipart/alternative; boundary="_000_43b4453b71644de69f2c064df2379920BY2PR03MB025namprd03pro_"
MIME-Version: 1.0
X-Forefront-Antispam-Report: CIP:; 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;; RD:InfoDomainNonexistent; MX:1; A:1; LANG:en;
X-Forefront-PRVS: 08331F819E
Received-SPF: pass client-ip=;;
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: 1UXbSY-0000Hs-Mx 7a47d45873063a5369fc0b70b5a76856
Subject: RE: Design Issue: Life-cycle of a Stream
Archived-At: <>
X-Mailing-List: <> archive/latest/17768
Precedence: list
List-Id: <>
List-Help: <>
List-Post: <>
List-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: [] On Behalf Of William Chan (???)
Sent: Wednesday, May 1, 2013 10:36 AM
To: James M Snell
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 <<>> 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

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