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

Takeshi Yoshino <tyoshino@google.com> Fri, 11 March 2011 00:53 UTC

Return-Path: <tyoshino@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 D2A4A3A6AA8 for <hybi@core3.amsl.com>; Thu, 10 Mar 2011 16:53:51 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -105.776
X-Spam-Level:
X-Spam-Status: No, score=-105.776 tagged_above=-999 required=5 tests=[AWL=0.200, 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 qSBtQG4sgHk7 for <hybi@core3.amsl.com>; Thu, 10 Mar 2011 16:53:50 -0800 (PST)
Received: from smtp-out.google.com (smtp-out.google.com [216.239.44.51]) by core3.amsl.com (Postfix) with ESMTP id 0247D3A6A03 for <hybi@ietf.org>; Thu, 10 Mar 2011 16:53:48 -0800 (PST)
Received: from kpbe15.cbf.corp.google.com (kpbe15.cbf.corp.google.com [172.25.105.79]) by smtp-out.google.com with ESMTP id p2B0t6Ah022726 for <hybi@ietf.org>; Thu, 10 Mar 2011 16:55:06 -0800
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1299804906; bh=McI4CD+Zrk9fbnpLThy6uCSmI1M=; h=MIME-Version:In-Reply-To:References:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ou3CzJ1R21ZQl0svXgd76Dbw0o7e4NmPhySiL8CLkcWqmghp+ENtXo22ZHvLPjcdV EBYIP4KSjRx8LREQiFHHg==
Received: from iwn33 (iwn33.prod.google.com [10.241.68.97]) by kpbe15.cbf.corp.google.com with ESMTP id p2B0slvk029734 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for <hybi@ietf.org>; Thu, 10 Mar 2011 16:55:05 -0800
Received: by iwn33 with SMTP id 33so3457203iwn.27 for <hybi@ietf.org>; Thu, 10 Mar 2011 16:55:05 -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=9nsii4R3e92tVFia9nv+KXLHq95RRQRsnxv7pLx1xeE=; b=kFlT+FUL8BZKxurHOESmURhxVvELJPczEo4W5mupqArIRQNWBdO2rE0zphHCHVGs75 Fyg/gmKaIifVHdrLuxGQ==
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=qnkPOLrcdAjnmL57/R8AiHFPvy7kiIgp0aV0mpANjYOg7q6V3jSsLaX6ZTWwwuwBXg HS50HV26o+vUYa967N3w==
Received: by 10.231.165.207 with SMTP id j15mr6703860iby.40.1299804905171; Thu, 10 Mar 2011 16:55:05 -0800 (PST)
MIME-Version: 1.0
Received: by 10.231.14.141 with HTTP; Thu, 10 Mar 2011 16:54:45 -0800 (PST)
In-Reply-To: <AANLkTi=3voS4ZZbrzp0uoDX6m6_ysY_DDg_mVP3e6P-9@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> <AANLkTi=3voS4ZZbrzp0uoDX6m6_ysY_DDg_mVP3e6P-9@mail.gmail.com>
From: Takeshi Yoshino <tyoshino@google.com>
Date: Fri, 11 Mar 2011 09:54:45 +0900
Message-ID: <AANLkTi=r3E1YYxKQEc-8LN13ohxBz-37_qTa6D8mFDUM@mail.gmail.com>
To: John Tamplin <jat@google.com>
Content-Type: multipart/alternative; boundary="000325572a1ea66acb049e2a695c"
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: Fri, 11 Mar 2011 00:53:51 -0000

On Fri, Mar 11, 2011 at 01:31, John Tamplin <jat@google.com> wrote:

> 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.
>

So, the note including zlib terms should go somewhere else than the spec
text.

IMO at least we should explain what implementors actually should do to align
to octet boundary, and place that somewhere they can easily get to. The
current deflate-stream spec just says "Senders MUST NOT delay the
transmission of any portion of a WebSocket message because the deflate
encoding of the message does not end on a byte boundary". It's not so easy
for implementors to know what to do and be convinced what they're doing is
correct. The octet aligning method is NOT explained in RFC1951. If we could
add some text like "For example, you can do this by adding BTYPE=00 block"
(and at least add reference to zlib since it's not our invention),
implementors can understand what to do just by reading WebSocket spec and
RFC1951. No need to use Z_ stuff.


>
> 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?
>
That's the quick fix to the deflate-stream extension I proposed above. I
want a short note in the spec saying that the sender should finalize the
stream after the close frame by BFINAL=1 block".

Some may immediately understand the deflate stream should finalized after
the close by just reading "Senders using this extension MUST apply RFC 1951
encodings to all bytes of the data stream following the handshake including
both data and control messages.", but expecting implementors to guess is not
good, I think.


>
> 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.
>

I agree this point. I'm not objecting to having deflate-stream in the
initial spec.


>   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
>