Re: WiSH: A General Purpose Message Framing over Byte-Stream Oriented Wire Protocols (HTTP)

Takeshi Yoshino <tyoshino@google.com> Wed, 02 November 2016 05:39 UTC

Return-Path: <ietf-http-wg-request+bounce-httpbisa-archive-bis2juki=lists.ie@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 6592C12950F for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Tue, 1 Nov 2016 22:39:38 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -7.997
X-Spam-Level:
X-Spam-Status: No, score=-7.997 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_HI=-5, RCVD_IN_SORBS_SPAM=0.5, RP_MATCHES_RCVD=-1.497, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=google.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xGOs7gQrpuID for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Tue, 1 Nov 2016 22:39:35 -0700 (PDT)
Received: from frink.w3.org (frink.w3.org [128.30.52.56]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 7212E129404 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Tue, 1 Nov 2016 22:39:34 -0700 (PDT)
Received: from lists by frink.w3.org with local (Exim 4.80) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1c1oCt-0001EV-4H for ietf-http-wg-dist@listhub.w3.org; Wed, 02 Nov 2016 05:35:27 +0000
Resent-Date: Wed, 02 Nov 2016 05:35:27 +0000
Resent-Message-Id: <E1c1oCt-0001EV-4H@frink.w3.org>
Received: from titan.w3.org ([128.30.52.76]) by frink.w3.org with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from <tyoshino@google.com>) id 1c1oCm-0001Ch-8z for ietf-http-wg@listhub.w3.org; Wed, 02 Nov 2016 05:35:20 +0000
Received: from mail-it0-f49.google.com ([209.85.214.49]) by titan.w3.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <tyoshino@google.com>) id 1c1oCf-0002Iw-PO for ietf-http-wg@w3.org; Wed, 02 Nov 2016 05:35:15 +0000
Received: by mail-it0-f49.google.com with SMTP id u205so16558376itc.0 for <ietf-http-wg@w3.org>; Tue, 01 Nov 2016 22:34:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=TMKfMwvP5y0rsT5IM61TrqtDZARZd5QZCxFCJKmnET4=; b=AF/UOcr3cwgJjGEMCnlRpYmfFsXZO5g1y5GOXXf8Q0yZ0uZLA9Ni44OJXu0Z1Ph4hp hpGzZc+zbuiLJgqusigdLt20zjy4uRL/9WVb+XTfnlgROQ+l8I/7GbB0lBmAkPOe5l9A rVnTX+ZZxJ0g25jJV8F7iZbvA1JyHdUvZ0vtwpP2vFjoBZ9UR/01EgBeDc1PRs3jyq35 fjNo53TKBz6QI8Xu/G0ipucTIcV6vmEa0m1eoEaeNJUxtM52dwcnK0XpB4g+0V7lS2uF AuJHzCZpOEt6Pm85rXN2qeBe38QhuA30wWMYpZkYcs3PJ7CwsejC8LhqpUQcKXwl/5Ch qRsw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=TMKfMwvP5y0rsT5IM61TrqtDZARZd5QZCxFCJKmnET4=; b=f9nrdmoMZylGhkN2TNSdUg1uKEBfzxZubxdchejwb0hYcVaO4FWWmPOLi87Mpemznx 7P/byf1zVQYzWvn2PPKuHUKlkMBwm3KRrKEc0TkUGnos8SCYCthuljTMmh+nzfk/paI9 5F52SMh/chN96wFUY9qYkrt09qNsJgfDJ2FGewnU0OF6HCDse3hxWQfVrw9HDRgrDBb6 MaLS9roJ0iL8eg9+xL3M8xU9lerrghqtsHHp/QuqmsqrzlzyAAilkybJC3HcKcH/rIFk GGtJ9CnhAdcU0K2tod1rK7sYekIjZnVbbQFD0Bg5G/ojduPYip/VJHw4OWBHNOQbjbPz y33A==
X-Gm-Message-State: ABUngvci5qz8SX2HFj4ILWjZOoWT1TFDPmWwze9DadqEoZNh/zmZ3Kx3xxuxY6XeXcEPHcZ2WKUVyDNHRmxo6o3f
X-Received: by 10.107.25.20 with SMTP id 20mr2321505ioz.189.1478064887587; Tue, 01 Nov 2016 22:34:47 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.79.113.68 with HTTP; Tue, 1 Nov 2016 22:34:26 -0700 (PDT)
In-Reply-To: <CAD3-0rM35uXJnwfGay-1s9uw=-P71EubOkxFdKF=gjoXub8YXw@mail.gmail.com>
References: <CAH9hSJZdBJ02+Z6o=aanZ=5PN=9VwyL1ZcX2jct-6f_FFivLGA@mail.gmail.com> <0f79ddf6-c455-c41a-f269-a1bdcef05b14@ninenines.eu> <CAH9hSJb2R9gv2vNqoyTjbMV4hZTYdpX2PoAoYgWUT1UuigLHRA@mail.gmail.com> <5541be74-afcc-6aef-404e-63acb2f608eb@ninenines.eu> <CAH9hSJarsNFqX1tAL7BZmZQwUrEQs1X3wtrAPuMyz8s-k_7WRg@mail.gmail.com> <43998e7b-9227-7562-b2c6-c08134065e22@ninenines.eu> <CAD3-0rPRPzVvYb6_Z4wDZp73L5Kyb7LmE0P5j4A-2VSRwT7FMw@mail.gmail.com> <CAH9hSJb=mWdHP8xcBis8-jhWgQTfN-cgQXVV3eCyT4U8JYQHZA@mail.gmail.com> <CAP8-FqnLaRvyQgXXkoNQPKcyMhv-O3RN67CMw5L_-1iQ9c6mhw@mail.gmail.com> <CAH9hSJYpsPW4S9n2LaaLTYYKB7wR3Sod2=fny2CZoUR7A0bSJA@mail.gmail.com> <CAP8-FqkOX1Sq6_=Sgb++QRiDWKEiOxAJ13kzMSr9heu-Ek3QmA@mail.gmail.com> <508f7085-b6b9-572e-7b0f-26cafc94dd44@ninenines.eu> <CAH9hSJZcGui08=DivN9vynKejvNFy+RYtRDYDnd6U6gxyX3UgQ@mail.gmail.com> <CAH9hSJZZCVMpQrpEV_JTceEmf2Y2aC_kJNXJmLW=LPebG+JR7g@mail.gmail.com> <CAP8-Fqk9SQJOuKWQmf5cRm9z2ja9wWUeG9xmivhiJf5O57Uryw@mail.gmail.com> <CAH9hSJZTVKx-8vg2xcqr_g4Bg+hc1ufvPZ2hZ+F=dXeVOdSu_Q@mail.gmail.com> <CAP8-Fqm=OVaOJ1imySM41_OuNu0D12Jby59dOpgqz-Bg4M+YOQ@mail.gmail.com> <CAD3-0rM35uXJnwfGay-1s9uw=-P71EubOkxFdKF=gjoXub8YXw@mail.gmail.com>
From: Takeshi Yoshino <tyoshino@google.com>
Date: Wed, 2 Nov 2016 14:34:26 +0900
Message-ID: <CAH9hSJZB0SyFiqLqLjd9R-T11yTa12Ekb-H8hYwfc6FeOjD2xQ@mail.gmail.com>
To: Wenbo Zhu <wenboz@google.com>
Cc: Costin Manolache <costin@gmail.com>, =?UTF-8?B?TG/Dr2MgSG9ndWlu?= <essen@ninenines.eu>, "ietf-http-wg@w3.org Group" <ietf-http-wg@w3.org>
Content-Type: multipart/alternative; boundary=001a113ffa2294ce6805404accc3
Received-SPF: pass client-ip=209.85.214.49; envelope-from=tyoshino@google.com; helo=mail-it0-f49.google.com
X-W3C-Hub-Spam-Status: No, score=-7.5
X-W3C-Hub-Spam-Report: AWL=1.725, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.505, SPF_PASS=-0.001, W3C_AA=-1, W3C_DB=-1, W3C_IRA=-1, W3C_WL=-1
X-W3C-Scan-Sig: titan.w3.org 1c1oCf-0002Iw-PO 51d0d4e5a59c38cdcd554b82c0c62ec1
X-Original-To: ietf-http-wg@w3.org
Subject: Re: WiSH: A General Purpose Message Framing over Byte-Stream Oriented Wire Protocols (HTTP)
Archived-At: <http://www.w3.org/mid/CAH9hSJZB0SyFiqLqLjd9R-T11yTa12Ekb-H8hYwfc6FeOjD2xQ@mail.gmail.com>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/32804
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>

On Mon, Oct 31, 2016 at 5:57 AM, Wenbo Zhu <wenboz@google.com> wrote:

>
>
> On Sun, Oct 30, 2016 at 10:25 AM, Costin Manolache <costin@gmail.com>
> wrote:
>
>> Thanks for the answer and pointers. From earlier responses, it seems
>> possible to use GET
>> or a non-web-stream request to would avoid the extra cost of the
>> pre-flight.
>>
>
>>
Yeah, at least the Content-Type in the HTTP request gets eliminated.


> One more question/issue: in some cases it would be good to send some
>> metadata (headers) along with binary frames. For example in webpush the
>> content is an encrypted
>> blob, and needs headers for the key/salt. I would assume a lot of other
>> 'binary' messages would
>> benefit if simple metadata could be sent along. Would it be possible to
>> use one of the reserved
>> bits for 'has metadata' and add some encoded headers ? I know in
>> websocket they are intended
>> for 'extensions', but 'headers' seems a very common use case.
>>
> Q about webpush: is the metadata different for each binary message?
>
> We discussed about metadata and how to use one of RSV bits etc. For the
> current version, let's make sure the WS compatibility is fully addressed
> (with minimum wire encoding like WiSH)
>

Agreed. Let's discuss the metadata needs separately. I agree it's important.


>
>
>>
>> Having the binary frame use some MIME encoding to pass both text headers
>> and the binary blob
>> is possible - but has complexity and overhead.
>>
> OTOH, if the binary blob relies on text headers (metata) to be useful,
> then you probably need define a dedicated MIME encoding.
>
>
>
>>
>> Costin
>>
>> On Sun, Oct 30, 2016 at 5:27 AM Takeshi Yoshino <tyoshino@google.com>
>> wrote:
>>
>>> Thanks, Van, Costin.
>>>
>>> On Sun, Oct 30, 2016 at 2:43 AM, Costin Manolache <costin@gmail.com>
>>> wrote:
>>>
>>> Good point - websocket is widely deployed, including IoT - and the
>>> header is pretty easy to handle anyways.
>>> +1.
>>>
>>> One question: is this intended to be handled by browsers, and exposed
>>> using the W3C websocket API ?
>>> Will a regular app be able to make WiSH requests and parse the stream by
>>> itself, without browser
>>> interference ? And if yes, any advice on how it interact with CORS ?
>>>
>>>
>>> The first step would be using Streams based upload/download via the
>>> Fetch API + protocol processing in JS.
>>>
>>> The next step could be either introduction of an optimized native
>>> implementation of WiSH parser/framer in the form of the TransformStream
>>> which can be used as follows:
>>>
>>> const responsePromise = fetch(url, init);
>>> responsePromise.then(response => {
>>>   const wishStream = response.body().pipeThrough(wishTransformStream);
>>>   function readAndProcessMessage() {
>>>     const readPromise = wishStream.read();
>>>     readPromise.then(result => {
>>>       if (result.done) {
>>>         // End of stream.
>>>         return;
>>>       }
>>>
>>>       const message = result.value;
>>>       // Process the message
>>>       // E.g. access message.opcode for opcode, message.body for the
>>> body data
>>>       readAndProcessMessage();
>>>     });
>>>   }
>>>   readAndProcessMessage();
>>> });
>>>
>>> and provide a polyfill that presents this as the WebSocket API, and (or
>>> skip the step and) go further i.e. native implementation for everything if
>>> it turns out optimization is critical.
>>>
>>> We need to discuss this also in W3C/WHATWG.
>>>
>>> Regarding CORS, if the request includes non CORS-safelisted headers,
>>> fetch() based JS polyfills will be basically subject to the CORS preflight
>>> requirement. We could try to exempt some of well defined headers if any for
>>> CORS like WebSocket handshake's headers and server-sent event's
>>> Last-Event-Id are exempted. Regarding the proposed subprotocol negotiation
>>> in the form of combination of the Accept header and the Content-Type
>>> header, the Accept header is one of the CORS-safelisted headers, so it's
>>> not a problem. The Content-Type header is considered to be
>>> non-CORS-safelisted if it's value is none of the CORS-safelisted media
>>> types. So, WiSH media type would trigger the preflight unless we exclude it.
>>>
>>> Origin policy https://wicg.github.io/origin-policy/ might also help.
>>>
>>>
>>>
>>> Costin
>>>
>>> On Fri, Oct 28, 2016 at 12:06 PM Takeshi Yoshino <tyoshino@google.com>
>>> wrote:
>>>
>>> Sorry for being ambivalent.
>>>
>>> We can of course revisit each design decision we made for RFC 6455
>>> framing and search for the optimal again. But as:
>>> - one of the main philosophies behind WiSH is compatibility with
>>> WebSocket in terms of both spec and implementation
>>> - the WebSocket is widely deployed and therefore we have a lot of
>>> implementations in various languages/platform
>>> - most browsers already have logic for the framing
>>> - the framing is not considered to be so big pain
>>> inheriting the WebSocket framing almost as-is is just good enough.
>>> Basically, I'm leaning toward this plan.
>>>
>>> Takeshi
>>>
>>> On Sat, Oct 29, 2016 at 3:12 AM, Takeshi Yoshino <tyoshino@google.com>
>>> wrote:
>>>
>>> On Sat, Oct 29, 2016 at 2:55 AM, Loïc Hoguin <essen@ninenines.eu> wrote:
>>>
>>> On 10/28/2016 08:41 PM, Costin Manolache wrote:
>>>
>>> Current overhead is 2 bytes if frame is up to 125 bytes long - which I
>>> think it's not very common,
>>> 4 bytes for up to 64k, and 10 bytes for anything larger.
>>> IMHO adding one byte - i.e. making it fixed 5-byte, with first as is,
>>> and next 4 fixed length would
>>> be easiest to parse.
>>>
>>>
>>> Is making it easy (or easier) to parse even a concern anymore?
>>>
>>> Considering the number of agents and servers already supporting
>>> Websocket, the numerous libraries for nearly all languages and the great
>>> autobahntestsuite project validating it all, reusing the existing code is a
>>> very sensible solution.
>>>
>>>
>>> Yeah, I've been having similar feeling regarding cost for parser/encoder
>>> implementation though I might be biased.
>>>
>>>
>>> There are obviously too many options to encode and each has benefits -
>>> my only concern was
>>> that the choice of 1, 2, 8 bytes for length may not match common sizes.
>>>
>>> ( in webpush frames will be <4k ).
>>>
>>>
>>> --
>>> Loïc Hoguin
>>> https://ninenines.eu
>>>
>>>
>>>
>>>
>