Re: [hybi] frame length encoding

Willy Tarreau <w@1wt.eu> Fri, 20 August 2010 19:28 UTC

Return-Path: <w@1wt.eu>
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 F367C3A694D for <hybi@core3.amsl.com>; Fri, 20 Aug 2010 12:28:59 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.802
X-Spam-Level:
X-Spam-Status: No, score=-2.802 tagged_above=-999 required=5 tests=[AWL=-0.759, BAYES_00=-2.599, HELO_IS_SMALL6=0.556]
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 OT6Syap3bJfR for <hybi@core3.amsl.com>; Fri, 20 Aug 2010 12:28:59 -0700 (PDT)
Received: from 1wt.eu (1wt.eu [62.212.114.60]) by core3.amsl.com (Postfix) with ESMTP id E2A653A68D8 for <hybi@ietf.org>; Fri, 20 Aug 2010 12:28:58 -0700 (PDT)
Received: (from willy@localhost) by mail.home.local (8.14.4/8.14.4/Submit) id o7KJTRjg032661; Fri, 20 Aug 2010 21:29:27 +0200
Date: Fri, 20 Aug 2010 21:29:27 +0200
From: Willy Tarreau <w@1wt.eu>
To: John Tamplin <jat@google.com>
Message-ID: <20100820192927.GA32620@1wt.eu>
References: <AANLkTimKbmcpgx8k0uXUWvCO=8w9pPrtV=3y4qh6363k@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <AANLkTimKbmcpgx8k0uXUWvCO=8w9pPrtV=3y4qh6363k@mail.gmail.com>
User-Agent: Mutt/1.4.2.3i
Cc: Hybi <hybi@ietf.org>
Subject: Re: [hybi] frame length encoding
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, 20 Aug 2010 19:29:00 -0000

Hi John,

On Fri, Aug 20, 2010 at 03:08:08PM -0400, John Tamplin wrote:
> Option 2
> ========
> Use 7 bits in the frame header, and if the value is 0-125, that is the
> length.  If the value is 126, then the next 2 bytes are a 16-bit length.  If
> the value is 127, the next 8 bytes are a 63-bit length (the high bit must be
> zero).
> 
> long long len = readByte();
> switch (len) {
>   case 126:
>     len = readUnsignedShort();
>     break;
>   case 127:
>     len = readLongLong();
>     break;
> }

This looks really nice and optimal to me !

+1 !

Willy