Re: [hybi] With deflate-stream, Close frame doesn't work as an end of data marker

John Tamplin <jat@google.com> Thu, 10 March 2011 16:30 UTC

Return-Path: <jat@google.com>
X-Original-To: hybi@core3.amsl.com
Delivered-To: hybi@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 4C4C23A6A3A for <hybi@core3.amsl.com>; Thu, 10 Mar 2011 08:30:22 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -105.824
X-Spam-Level:
X-Spam-Status: No, score=-105.824 tagged_above=-999 required=5 tests=[AWL=0.152, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-4, USER_IN_WHITELIST=-100]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qXXwd-uuMqbZ for <hybi@core3.amsl.com>; Thu, 10 Mar 2011 08:30:21 -0800 (PST)
Received: from smtp-out.google.com (smtp-out.google.com [74.125.121.67]) by core3.amsl.com (Postfix) with ESMTP id CCF8A3A6A1A for <hybi@ietf.org>; Thu, 10 Mar 2011 08:30:20 -0800 (PST)
Received: from wpaz21.hot.corp.google.com (wpaz21.hot.corp.google.com [172.24.198.85]) by smtp-out.google.com with ESMTP id p2AGVbk3014796 for <hybi@ietf.org>; Thu, 10 Mar 2011 08:31:37 -0800
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1299774698; bh=dIk9Ku1DM0eaBWxgTtv6tY2UgY4=; h=MIME-Version:In-Reply-To:References:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=H7F2HMQB78JsXQ1HepOCmbbDtVZUNX0mGzckSe2Piqw67ceHmvxIVB6RLFrskB0SF Pd2kxQKyQQ64nYRXopttg==
Received: from yia27 (yia27.prod.google.com [10.243.65.27]) by wpaz21.hot.corp.google.com with ESMTP id p2AGUeMC021604 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <hybi@ietf.org>; Thu, 10 Mar 2011 08:31:36 -0800
Received: by yia27 with SMTP id 27so836110yia.33 for <hybi@ietf.org>; Thu, 10 Mar 2011 08:31:36 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=beta; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=GA92UaFbd9p2gIYpAxCgg2ouWOOxHB2TL3/VgBPS0nU=; b=fGApwwpewi8L6Gii7sGTLscYoK4vFst5FAyCXidMecTfFaXN67Dfblkug22S5dYRT1 0YXiUz6qzpx/G6QUsmLg==
DomainKey-Signature: a=rsa-sha1; c=nofws; d=google.com; s=beta; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=oDSjtFTFvW97RSZNA5oKU+g9BbzaR7lLtQQQB6esMOHRTxqujtFELo7Wq4Lwb5AhfK dLaY0NB6KkzLHz0i4AUA==
Received: by 10.151.157.9 with SMTP id j9mr1244285ybo.409.1299774696157; Thu, 10 Mar 2011 08:31:36 -0800 (PST)
MIME-Version: 1.0
Received: by 10.150.200.16 with HTTP; Thu, 10 Mar 2011 08:31:16 -0800 (PST)
In-Reply-To: <AANLkTi=eujUtQY64Uoo0ymTM013hT-ebMb8j-cXF6m9i@mail.gmail.com>
References: <OF4821AA00.120197B4-ON8825784E.0076F791-8825784E.00781253@playstation.sony.com> <4D77FB84.9010104@warmcat.com> <AANLkTin+JizCJ-tgr1bxTygaT_2ueT910JByq9BYGncS@mail.gmail.com> <4D789223.8010208@warmcat.com> <AANLkTikabAwUv5g=F7OHjmGy_rei=jCGhr8ypiGP8sdO@mail.gmail.com> <4D78C12C.1080108@warmcat.com> <AANLkTi=eujUtQY64Uoo0ymTM013hT-ebMb8j-cXF6m9i@mail.gmail.com>
From: John Tamplin <jat@google.com>
Date: Thu, 10 Mar 2011 11:31:16 -0500
Message-ID: <AANLkTi=3voS4ZZbrzp0uoDX6m6_ysY_DDg_mVP3e6P-9@mail.gmail.com>
To: Takeshi Yoshino <tyoshino@google.com>
Content-Type: multipart/alternative; boundary="001517510fdc0d72cb049e236136"
X-System-Of-Record: true
Cc: hybi@ietf.org, Yutaka_Takeda@playstation.sony.com
Subject: Re: [hybi] With deflate-stream, Close frame doesn't work as an end of data marker
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hybi>
List-Post: <mailto:hybi@ietf.org>
List-Help: <mailto:hybi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 10 Mar 2011 16:30:22 -0000

On Thu, Mar 10, 2011 at 7:34 AM, Takeshi Yoshino <tyoshino@google.com>wrote:

> OK. So we can add an implementation note like this.
>
> Senders using this extension MUST apply RFC 1951 DEFLATE to all the bytes
>> of the application data portion of data frames. Senders MAY include multiple
>> blocks in a frame. Senders MAY use blocks of any type as defined in RFC
>> 1951. Senders MUST use the algorithm described in Section 2.1 of RFC1979 to
>> align compressed data to byte boundary. Senders MAY keep using the same LZ77
>> sliding window for multiple frames.
>
>
> If you're using zlib for applying DEFLATE compression, specify Z_SYNC_FLUSH
> when you flush the last octets of application data for each frame (in case
> the last block is non-compressed block (BTYPE=00), append one empty
> compressed block (BTYPE=01)), and then strip the last 4 octets from the
> compressed octets.
>
> Receivers MUST append 0x00 0x00 0xff 0xff to the application data portion
>> and decompress it using DEFLATE to decode the original application data.
>> Receivers MUST keep using the same LZ77 sliding window for all the frames of
>> the same WebSocket connection. Receivers MUST assume the senders use 32768
>> byte LZ77 sliding window.
>
>
> If you're using zlib for applying DEFLATE compression, for each received
> frame, concatenate 4 octets 0x00 0x00 0xff 0xff and the application data,
> and then supply the resulting bytes to zlib and use the uncompressed data.
>

zlib is just one implementation, and I don't think the spec should be
choosing one implementation instead of the algorithm.  Therefore, we
shouldn't be using zlib-specific terminology in the spec.

I don't object to compressing only the payload (though it does make
implementations more complicated, rather than just pushing a
compressor/decompressor onto the stream having to switch back and forth),
but couldn't the issue we are trying to solve here be done by just saying
that if deflate-stream is negotiated and a close frame is read, you cannot
initiate close processing until the final compressed block is read
completely?

In any case, I think deflate-stream is only a stop-gap solution to get some
form of compression in the spec, also serving as an example extension.  I
think realistically we are going to have to have the ability to avoid
compressing incompressible data in the stream.  Initially, where WebSockets
implementations only support plain text, this won't be much of a problem,
but eventually clients will be mixing binary data with their text and we
would prefer to be able to use compression where it helps and not use it
where it hurts.

-- 
John A. Tamplin
Software Engineer (GWT), Google