[whatwg] WebSocket bufferedAmount includes overhead or not

Olli Pettay Olli.Pettay at helsinki.fi
Thu Mar 25 11:26:06 PDT 2010


On 3/25/10 5:55 PM, Anne van Kesteren wrote:
> On Thu, 25 Mar 2010 16:35:19 +0100, Olli Pettay
> <Olli.Pettay at helsinki.fi> wrote:
>> On 3/25/10 4:25 PM, Niklas Beischer wrote:
>>> Easy. The bufferedAmount is: "The amount of bytes waiting to be
>>> transferred, including protocol overhead".
>> That doesn't define exactly what the bufferedAmount means and what
>> kinds of values are expected.
>> What I'd expect the API to tell me is, for example, that if I call
>> ws.send(foo), and nothing is yet sent over the network, what is the
>> exact value of bufferedAmount.
>> Again, I'd really wish to keep the API to work reasonable similar
>> way as XHR+progress events where protocol overhead isn't reported.
>
> Why? Progress events are completely different from this. This is about
> not saturating the network with too much data; it makes sense if the
> actual amount of data that is going to hit the network is known.

bufferedAmount is not only about "not saturating".

Let's put the question otherway around:
from API point of view, why should bufferedAmount contain some bytes
which aren't specified in the API spec?
If the API specifies that bufferedAmount is always 
to_be_sent_data_in_UTF8_length+(1 or 2), that would be sort of ok.
Very very ugly, but ok.

Also, some implementations may not put the protocol
overhead bytes to the buffer at all, but just write them to the
socket when needed.



-Olli


  (Yes, I
> changed my mind.)
>
>




More information about the whatwg mailing list