Re: [hybi] permessage-compression / permessage-deflate configuration is too complex

Takeshi Yoshino <tyoshino@google.com> Fri, 26 April 2013 03:53 UTC

Return-Path: <tyoshino@google.com>
X-Original-To: hybi@ietfa.amsl.com
Delivered-To: hybi@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 2CBEB21F8EEA for <hybi@ietfa.amsl.com>; Thu, 25 Apr 2013 20:53:48 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -101.977
X-Spam-Level:
X-Spam-Status: No, score=-101.977 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, NO_RELAYS=-0.001, USER_IN_WHITELIST=-100]
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 HxnD4l6r0djP for <hybi@ietfa.amsl.com>; Thu, 25 Apr 2013 20:53:47 -0700 (PDT)
Received: from mail-wi0-x22e.google.com (mail-wi0-x22e.google.com [IPv6:2a00:1450:400c:c05::22e]) by ietfa.amsl.com (Postfix) with ESMTP id F05E921F8432 for <hybi@ietf.org>; Thu, 25 Apr 2013 20:53:46 -0700 (PDT)
Received: by mail-wi0-f174.google.com with SMTP id m6so135389wiv.13 for <hybi@ietf.org>; Thu, 25 Apr 2013 20:53:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=N5edr4vTGillGI4ZqQI4yYVEVdOdGbEn8x6ASWTX3LY=; b=Z5UWrrNdYPl+UKLAYa76UrqhIOzlB53HC0Ts3fqtinF31wFU3EeRvwJr/D8opa4Koc SaYiPJE+PtGLDgX+f55qzsCqLM0vffy1LUqeUDqRVAKHQIsMgvbKdXgXY2rNHDjfe07d S5yR6jEb9nxPfQvKtQFIJeSmZosu7HpX1xr/ZlQgo5YFbe4WAIRuuZAGYB+C6HOV2iIm jzD1vFsXctkMEagzYs0yeE36qPpkUpnhLPGx4jtHePnQ3QCPjU3XCTB1XNXTkxLyi6cS Cq0ar9xOI54zEFJJHyrqSuwC8ELZlEMyrNj5DgFyElxgxeR8VA2ngKvxX1/EgODw8UR1 vkWw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:x-gm-message-state; bh=N5edr4vTGillGI4ZqQI4yYVEVdOdGbEn8x6ASWTX3LY=; b=d6C3qrhCjwfgV1geJsX3RV90lyZUD3S6oqcK56TMrGDD0CKoL5WRqY5cLY5Wsx8WaR v0HAqU5AlXlMOBzSepvdxxYO89BzeygQVV+AzrVWsPSjj60V6fBP4JBgCIYJ6/8hczHA AMY8I0NfQfuI3b8fhlmOTW7bCQoWh6L7Pu3SDET3X4gL9KOmrAejsvPewGTQLY62m6vV 9ClikFdI+HyRFNoRu1Jkk5nw9hSg2Zq63xWU1rw170dBXXU+x1nc9w9SzfFt+vL3VF5+ Hi8+9/WEzcOyrjYb82o0scuLxf2KPwEHQNV7VdxLqGj5Ed3I1X60tp0/EOVLWyqYihIS Df2w==
X-Received: by 10.194.143.50 with SMTP id sb18mr79272482wjb.44.1366948426080; Thu, 25 Apr 2013 20:53:46 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.194.167.42 with HTTP; Thu, 25 Apr 2013 20:53:26 -0700 (PDT)
In-Reply-To: <25D2499B-BC3C-4232-8697-FFDE76E06A8D@zaphoyd.com>
References: <CAG4zZZDhm-t=GXZXk3_hHN9vYJcgNYFBC-5REs0faCyARoKz3A@mail.gmail.com> <25D2499B-BC3C-4232-8697-FFDE76E06A8D@zaphoyd.com>
From: Takeshi Yoshino <tyoshino@google.com>
Date: Fri, 26 Apr 2013 12:53:26 +0900
Message-ID: <CAH9hSJbbvkq9xGuEX6eh4ZAbFScA8t2-E+7N3RVkpYOi4ANtMQ@mail.gmail.com>
To: Peter Thorson <webmaster@zaphoyd.com>
Content-Type: multipart/alternative; boundary="089e0115f79a5cf78804db3b7b2e"
X-Gm-Message-State: ALoCoQn1VTm/yccByWi57j2GIfBBaXgOMGePXNR/sZCQ+WBVydkKuWg2iBM0+/afjgEKSSVH2d11Ej/VcGnQdbx8PcG5eYjzofIbWDjrDNzAe4a1K28iXE+UnkMas8uvT5TzOpcWTFnXueikkrfriWvttPn8glAMJ+trw1jeMpN+hLBsahluIw4KY8zJ24SB+jy107OE7oCV
Cc: "hybi@ietf.org" <hybi@ietf.org>
Subject: Re: [hybi] permessage-compression / permessage-deflate configuration is too complex
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/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, 26 Apr 2013 03:53:48 -0000

On Fri, Apr 26, 2013 at 7:38 AM, Peter Thorson <webmaster@zaphoyd.com>wrote:

> On Apr 25, 2013, at 09:53 , Joakim Erdfelt <joakim@intalio.com> wrote:
>
> How can a server side implementation respond on a the extension
> negotiation for this spec, using the permessage-deflate saying, "sorry, we
> don't support the C-library tweaks present in the spec and will only use
> default behavior" or to say "sorry, we don't support the C-library tweaks
> present in the spec and will only use the following behavior for both c2s
> and s2c streams"
>
> The current language in permessage-compression-09 (Section 8) says:
>
>    A server MUST decline a "permessage-deflate" offer if any of the
> following conditions is met:
>       o  The offer has any extension parameter not defined for use in an
> offer.
>       o  The offer has any extension parameter with an invalid value.
>       o  The offer has multiple extension parameters with the same name.
>       o  The server doesn't support the offered configuration.
>
> That last bullet point is the crux of the problem I'm facing.  How can the
> negotiation indicate that "yes, i support permessage-deflate, but only this
> specific configuration, that doesn't match up to your configuration to
> permessage-deflate"
>
> I'd like to propose that all of the following concepts be removed from the
> permessage-deflate and just standardized for specific default behavior
> based on a sensible set of defaults (lowest common denominator?), similar
> to how HTTP's content codings work (the http spec does not tweak
> compression algorithms) ...
>
> c2s_max_window_bits
> c2s_no_context_takeover
>
> s2c_max_window_bits
> s2c_no_context_takeover
>
> from a Java point of view these are not possible to support without
> re-implementing the entire java.util.zip.Deflate library in each java
> application. (default Deflate support, that ships with every copy of Java
> since 1.0, just does not support these tweaks)
>
> --
> Joakim Erdfelt <joakim@intalio.com>
>
>
> Section 8.1.3 explains how to handle this case:
>
> A client sending: `Sec-WebSocket-Extensions: permessage-deflate;
> s2c_no_context_takeover, permessage-deflate` is asking "I would prefer
> that you reset the sliding window for each message, but if you can't then
> the defaults are acceptable." The server could then choose which copy of
> the extension request to return based on what it supports.
>
> A client sending: `Sec-WebSocket-Extensions: permessage-deflate; s2c_no_context_takeover`
> is asking "I don't have the memory to spare for a default sliding window
> context per connection. We can compress if you support window resetting, if
> not we can't use compression."
>
> Removing these options would not enable a Java based endpoint to compress
> connections that it otherwise wouldn't have been able to. It only removes
> the ability for non-Java endpoints to optimize their resource usage.
>
> Peter
>

The minimal set of functionality necessary to conform to this spec as a
server is s2c_no_context_takeover. That's all. I believe Java SE can
implement it.

- Compression: use java.util.zip.Deflater and append 0x00 at the end. If
received s2c_no_context_takeover, just recreate Deflater instance for each
message.
- Decompression: add 0x00 0x00 0xff 0xff to the end of message payload,
decompress it using java.util.zip.Inflater. When you see the end of DEFLATE
stream, recreate Inflate object and continue processing the rest.

- You don't need to care c2s_max_window_bits and c2s_no_context_takeover.
Just don't send them.
- You can just ignore c2s_max_window_bits capability announcement coming
from the client since you don't use it.
- You should just reject requests with s2c_max_window_bits. Clients should
take the way Peter explained above.

We're not sure if window bits is win for WebSocket or not, so I'd prefer
having it in the spec now. If it turned out to be win, you might be asked
to support it by users. Otherwise, everyone forgets them. Anyway, you can
make your server conform to the spec by supporting only
s2c_no_context_takeover.

Similarly, the minimal set clients need to support is
c2s_no_context_takeover.

Thanks