Re: Data API: what is agreed, what is open

Stefan Hakansson LK wrote:
>>> * The API should initially enable sending and receiving DOMString,
>>> Blob and ArrayBuffer data
>>
>> Like to know more but suspect I won't care
>
> This is basically the data types that you can send/receive with
> WebSockets, so it is an alignment.

I was curious how WebSockets distinguishes these things on the wire, so 
I did some digging. The WebSockets protocol 
(http://www.rfc-editor.org/rfc/rfc6455.txt) has a 4-bit "opcode" field 
that lets it specify "binary" or "text" data messages and can signal 
various control messages ("close", "ping", "pong", etc.).

But it doesn't distinguish between "Blob" and "ArrayBuffer". Instead, 
the WebSocket API (http://dev.w3.org/html5/websockets/) has a 
user-settable "binaryType" attribute, which can be set to the string 
"blob" or "arraybuffer", and whatever incoming binary messages arrive 
will be delivered as an object of that type. Incoming text messges are 
delivered as DOMStrings (they have to be distinguished from binary, 
because of the need to convert the on-the-wire UTF8 to and from whatever 
JS-land is expecting). On the sending side, DOMStrings go out as "text" 
and both Blobs and ArrayBuffers go out as "binary".

Also, despite protocol support for 16 exabyte messages, they are limited 
to 16 MB by default.

Received on Monday, 13 February 2012 18:55:18 UTC