> In the discussion of protocol layers, there were arguments made in
> favor of both socket-based and HTTP based protocols, though not much
> objection to JSON as a data format.
So JSON is the data format. +1
> So I would propose going ahead with both transports, and suggest the
> following packet formats:
>
> Socket: ascii message-length, null-byte, ascii message, null-byte
Why not make it more textual; the payload for content-encoding:
chunked seems kind of appropriate, which is basically uses whitespace
where you specify null bytes.
http://en.wikipedia.org/wiki/Chunked_transfer_encoding
> HTTP: POST request, message as x-www-form-urlencoded in request body.
Why x-www-form-urlencoded? Presumably JSON objects serialized to a
string would be sent to the server, and received back, in which case
use application/json for both.
Patrick Mueller - http://muellerware.org/
I'm not quite understanding what using form-encoded would mean. Would
you send a JSON payload as the value of a form key? So a request body
for a POST would look something like this:
json={"x":2}
which would actually need to get sent as this, to handle the form
encoding:
json=%7B%22x%22%3A2%7D
I'm not quite understanding what using form-encoded would mean. Would
you send a JSON payload as the value of a form key? So a request body
for a POST would look something like this:
json={"x":2}
which would actually need to get sent as this, to handle the form
encoding:
json=%7B%22x%22%3A2%7D
My simple example could in theory be sent as
x=2
which you might imagine would get treated as:
{"x":2}
which has some nice properties; everyone can already easily deal with
form encoding, etc.
Problems are, you can't indicate a type, so what you'd really likely
have to translate that form body to is:
{"x": "2"}
And dealing with nested objects sends you back to the pits of hell.
So while it should never be used as a general encoding mechanism,
there might be some rational for actually allowing it for highly
constrained objects - "single level" objects whose properties are all
string values, specifically. Just seems hardly worth the hassle.
I think you're suggesting that you could extend an existing web server
with something that read HTTP transfer-encoded chunks from a non-HTTP
socket and fed them to someone else as HTTP requests/responses. At
that point, your biggest problem is that you have to write an
extension to a web server; dealing with a different "chunk" ending
isn't an issue anymore, priority-wise. :-)