Re: [hybi] WS framing alternative

"Thomson, Martin" <Martin.Thomson@andrew.com> Tue, 27 October 2009 22:11 UTC

Return-Path: <Martin.Thomson@andrew.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 967033A6933 for <hybi@core3.amsl.com>; Tue, 27 Oct 2009 15:11:31 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.559
X-Spam-Level:
X-Spam-Status: No, score=-2.559 tagged_above=-999 required=5 tests=[AWL=0.040, BAYES_00=-2.599]
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 0Se0tYjo06A3 for <hybi@core3.amsl.com>; Tue, 27 Oct 2009 15:11:30 -0700 (PDT)
Received: from csmailgw1.commscope.com (csmailgw1.commscope.com [198.135.207.243]) by core3.amsl.com (Postfix) with ESMTP id 94BDA3A6A4A for <hybi@ietf.org>; Tue, 27 Oct 2009 15:11:30 -0700 (PDT)
Received: from [10.86.20.103] ([10.86.20.103]:5195 "EHLO ACDCE7HC2.commscope.com") by csmailgw1.commscope.com with ESMTP id S4830791AbZJ0WLo (ORCPT <rfc822; hybi@ietf.org>); Tue, 27 Oct 2009 17:11:44 -0500
Received: from SISPE7HC1.commscope.com (10.97.4.12) by ACDCE7HC2.commscope.com (10.86.20.103) with Microsoft SMTP Server (TLS) id 8.1.393.1; Tue, 27 Oct 2009 17:11:44 -0500
Received: from SISPE7MB1.commscope.com ([fe80::9d82:a492:85e3:a293]) by SISPE7HC1.commscope.com ([fe80::8a9:4724:f6bb:3cdf%10]) with mapi; Wed, 28 Oct 2009 06:11:41 +0800
From: "Thomson, Martin" <Martin.Thomson@andrew.com>
To: Ian Hickson <ian@hixie.ch>
Date: Wed, 28 Oct 2009 06:12:07 +0800
Thread-Topic: [hybi] WS framing alternative
Thread-Index: AcpW5Y/fI6aOPoUNSDueThJsw/4tygAabRYg
Message-ID: <8B0A9FCBB9832F43971E38010638454F0F25151E@SISPE7MB1.commscope.com>
References: <8B0A9FCBB9832F43971E38010638454F0F1EA72C@SISPE7MB1.commscope.com> <Pine.LNX.4.62.0910270903080.9145@hixie.dreamhostps.com>
In-Reply-To: <Pine.LNX.4.62.0910270903080.9145@hixie.dreamhostps.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
acceptlanguage: en-US
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
MIME-Version: 1.0
X-BCN: Meridius 1000 Version 3.4 on csmailgw1.commscope.com
X-BCN-Sender: Martin.Thomson@andrew.com
Cc: "hybi@ietf.org" <hybi@ietf.org>
Subject: Re: [hybi] WS framing alternative
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: Tue, 27 Oct 2009 22:11:31 -0000

Hi Ian,

> -----Original Message-----
> From: Ian Hickson [mailto:ian@hixie.ch]
> Sent: Tuesday, 27 October 2009 8:12 PM
> To: Thomson, Martin
> Cc: hybi@ietf.org
> Subject: Re: [hybi] WS framing alternative
> 
> On Tue, 27 Oct 2009, Thomson, Martin wrote:
> >
> > WS is binary.
> 
> WS is really a text/binary hybrid. 

...which is even worse.  A hybrid loses the benefits of either approach.  But I tend to think of WS as a purely binary protocol that occasionally looks like text (the header) and can only have textual payloads (frame bodies).  That's consistent with its description.

> > There would be little cost in a minor change that would also enable
> use
> > of MIME.
>
> This would have some pretty major costs:
> 
> - It requires length delimiting for text frames, which is more
> complicated
> to implement (it's non-trivial to tell the difference between
> characters
> and bytes).

I agree with Greg on this point.  Sentinel-based delimiting has its own complexity costs.  Either position has been presented in the rhetoric as better or worse depending on what you value most.

> - It requires parsing using a presized buffer for variable-encoding
> text,
> which risks character/byte mismatches and thus buffer overruns.

That's untrue.  

Or you've made an assumption about my proposal that I never stated: i.e. that length is stated in characters.  Which would, of course, lead to these conclusions.  My intent (which I incorrectly assumed would be clear) was that length was octets.  It seems obvious to me - character encoding changes with different content types, thus you can't use character-based encodings.

> - It allows arbitrary extensions, which introduces an implementation,
> QA,
> documentation, and tutorial cost without providing any new features at
> the
> API level.

Yes, arbitrary extensions have a cost, but I believe that we've benefitted from others having the wherewithal to pay that price before.

Besides, there are two mitigating factors:

 - When interoperating between vendors you cannot guarantee that the opposite end supports an extension, therefore you have to be prepared for them to ignore it.  Therefore, there is no reason that an implementation couldn't do as I suggested and ignore ALL extensions.

 - When not interoperating (the standard web sockets use case of JS talking to the same server), if there's no benefit gained from having extensions, then they can again be ignored.

> - It makes it possible for the headers to have errors in them, which
> requires us to define how to handle errors, and requires significantly
> more code to implement the parsing.

Only if you require syntax checking of the headers.  If you allow for simple ignoring of headers, then it's straight back to the original.

> I disagree that it's minimal.

Excellent.  Then we all disagree ;)

> > Rather than sending:
> >
> >   [0x80, 0x0d]Hello, World!
> 
> Currently you would send a text frame thus:
> 
>    [0x00] Hello, World! [0xFF]

Sure.  See below.

> >   4+
> >
> >   Hell
> >   9
> >
> >   o, World!
> 
> That seems like orders of magnitude more complexity than necessary,
> especially given that the only tangible benefit is a modicum of
> improvement in ease of debugging.

That's why I'm not particularly wed to the idea.  Just like I'm not sold on the benefits of being able to start sending data without knowing its length beforehand.  That's complexity without benefit as far as I can tell.

It's hardly orders of magnitude of complexity, though.  Don't wear out your superlatives.

--Martin