[PATCH 1 of 1] sshserver: add varargs capability

Sune Foldager cryo at cyanite.org
Wed Feb 10 16:55:28 CST 2010


Ok, here's a proposal; I'll start to implement parts of it soon, I
think, and we can discuss the details :).

1. Protocol versions
We'll call the current protocols used version 1, and the new ones
version 2. Versions will in general be positive integers; we need not
keep the different wire protocol versions identical, but this time
around we'll advance both.

2. Common features
- Capabilities: protocol=1,2 or similar, from server to client as usual.
- Request: client can communicate protocol version used.
- Request: command name + variable arguments OR
           command name + JSON (let's discuss which one).
- Response: separate output and error stream.

3. SSH
Initial line will be:
<protocol version> <command name> [possible version dependent data]

For version 2:
2 <command name> <argument count>  OR
2 <command name> <argument length> (in case of JSON)
<arguments as before, or JSON as a single chunk>

We can thus easily tell the current version from the new one.

4. HTTP
Protocol version will be put in X-Protocol: <version number> header.
Response stream will be segmented using an approach similar to chunked
transfer encoding: Each chunk/segment will start with a line containing
the size of the segment and its type (output or error), for instance:
<size in decimal, hex or whatever> <type>
followed by data. A 0-chunk terminates the stream, if we think it necessary.

In case of a server error, we pad the current (output) chunk, and send
an error chunk afterwards. The client MUST check for trailing error
chunks, as their presense can mean that the previous output chunk is
invalid.

This is what I had in mind; note that this only addresses the protocol
proper, and not its possible unification in the code. It's a step in the
right direction, however, as the feature set will now be unified.

/Sune



More information about the Mercurial-devel mailing list