[whatwg] WebSocket bufferedAmount includes overhead or not.
Alexey Proskuryakov
ap at webkit.org
Fri Mar 5 09:54:24 PST 2010
On 04.03.2010, at 1:52, Olli Pettay wrote:
>> I noticed that WebSocket spec updated to not inlcude framing
>> overhead in
>> bufferedAmount.
> I asked that since from API point of view it doesn't make
> much sense to have the frame bytes to be magically included in the
> bufferedAmount.
> What if we change the protocol and require different amount framing
> bytes?
I was going to mention this as the primary reason why frame bytes
should be included. JavaScript code needs this information for flow
control, and it's raw bytes that are sent over the tubes, not original
message strings.
Also, I think it's a layering violation. In WebKit, we'd have to queue
unsent messages separately just to implement this quirk (see https://bugs.webkit.org/attachment.cgi?id=50093
for a proof of concept). It becomes very difficult to implement we
decide to add size of data that an underlying network library buffers
internally - which I think would be a reasonable thing to do.
> Also why to have framing bytes and not the bytes related to http
> handling?
Nothing would change for engines or JS code if HTTP headers were
counted in bufferedAmount. Since they are only sent when establishing
a connection, adding a small constant at the beginning will make no
difference to flow control. And the constant is going to be zero in
practice, because the data will immediately go where we can't see it.
- WBR, Alexey Proskuryakov
More information about the whatwg
mailing list