Re: [hybi] Fragmented text message
Brian <theturtle32@gmail.com> Thu, 21 July 2011 08:47 UTC
Return-Path: <theturtle32@gmail.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 283E721F8B83 for <hybi@ietfa.amsl.com>; Thu, 21 Jul 2011 01:47:19 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.598
X-Spam-Level:
X-Spam-Status: No, score=-3.598 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-1]
Received: from mail.ietf.org ([64.170.98.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AwRnyUDLanpF for <hybi@ietfa.amsl.com>; Thu, 21 Jul 2011 01:47:15 -0700 (PDT)
Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by ietfa.amsl.com (Postfix) with ESMTP id BD5E121F8B7C for <hybi@ietf.org>; Thu, 21 Jul 2011 01:47:14 -0700 (PDT)
Received: by fxe4 with SMTP id 4so3704604fxe.27 for <hybi@ietf.org>; Thu, 21 Jul 2011 01:47:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=R6moYFXgnV3+xpDghZLBnd8t3zqB7iBpJS75QF/1j/A=; b=N89yK+5NvtOiOrrfZtr69luy5Uaj8Bccf2GCGUIDkGaQGJlw7Sbjhm+rDFQts5wEt0 d4JSb6ieJo4FHef9b/xvhoQpmFgb/UknBnG4V0I9U2jQ/OuWM9wRp7+yi9zKNxckEDe4 QwzE9ldZsK3DAL1tVTVVh+Ax898FL900vJ3pw=
MIME-Version: 1.0
Received: by 10.204.142.14 with SMTP id o14mr2093bku.15.1311238031204; Thu, 21 Jul 2011 01:47:11 -0700 (PDT)
Received: by 10.204.73.65 with HTTP; Thu, 21 Jul 2011 01:47:11 -0700 (PDT)
In-Reply-To: <EC24CA2C319E8D47ACA5E181ABEC3E7B13BA5205BB@MCHP058A.global-ad.net>
References: <EC24CA2C319E8D47ACA5E181ABEC3E7B13BA5205BB@MCHP058A.global-ad.net>
Date: Thu, 21 Jul 2011 01:47:11 -0700
Message-ID: <CAE8AN_UmK-r2OskQG+QuRPgAWOg7S0BN6vfKLyDPPp2fAFDReQ@mail.gmail.com>
From: Brian <theturtle32@gmail.com>
To: "Kukosa, Tomas" <tomas.kukosa@siemens-enterprise.com>
Content-Type: multipart/alternative; boundary="0015174c3ca610e1ad04a89065db"
Cc: "hybi@ietf.org" <hybi@ietf.org>
Subject: Re: [hybi] Fragmented text message
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: Thu, 21 Jul 2011 08:47:19 -0000
Unless I'm mistaken, the fragmentation may occur in the middle of a multi-byte character sequence. Your code should be aware of that when decoding. My initial implementation buffers all fragments and then decodes the whole message into a string at once. I imagine you could probably inspect the last four bytes of a fragment to determine whether there's a partial utf-8 character. If there is, you could buffer just those few bytes and decode the rest of the fragment. Then when the next fragment comes in, prepend those bytes to the new payload and continue. Depending on your use case and what you're optimizing for, it may be more efficient to just buffer the whole message and then decode. Brian On Thu, Jul 21, 2011 at 1:28 AM, Kukosa, Tomas < tomas.kukosa@siemens-enterprise.com> wrote: > Hi, > > I have a one question regarding fragmented text messages. > > If the text message is fragmented must be each fragment a valid UTF-8 > string or only complete defragmented message must be a valid UTF-8 string? > I.e. may I during receiving decode each fragment by UTF-8 and than join > strings or do I need to receive all fragments and then decode only > defragmented message? > > Thanks, > Tomas > _______________________________________________ > hybi mailing list > hybi@ietf.org > https://www.ietf.org/mailman/listinfo/hybi >
- [hybi] Fragmented text message Kukosa, Tomas
- Re: [hybi] Fragmented text message Brian
- Re: [hybi] Fragmented text message Takeshi Yoshino
- Re: [hybi] Fragmented text message Piotr Kulaga
- Re: [hybi] Fragmented text message David Endicott
- Re: [hybi] Fragmented text message John Tamplin