Dioscuri, another application layer protocol

Dioscuri is a protocol intended to supplement Gemini for doing things like
uploading files, performing remote actions, and running an application
server.  It is the POST to Gemini's GET.  Dioscuri servers will run on a
different port altogether, so that they do not interfere with Gemini
servers.  Dioscuri, unlike Gemini, absolutely *requires* the use of client
certificates.

Great thanks to the members of irc://tilde.chat/gemini, especially lukee
and aravk.

The name "Dioscuri" is the Latinized spelling of the Greek name for the
Heavenly Twins, Castor and Pollux/Polydeukes, who were called Gemini in
Latin; the constellation is named after them.  I say dee-OH-skoo-ree, but
Greeks, classicists, and others should feel free to pronounce the name
their way.

=======

A Dioscuri request starts out with the client sending a single line,
<URL><SP><MEDIA-TYPE><CR><LF>.  This indicates that a body follows which
should be interpreted according to the media type.  For example, "gemini://
example.org/foo text/gemini\r\n" means that the Dioscuri server should do
something with the following body, which is of type text/gemini.  Exactly
what happens depends on the server and the URL.  For example, it might
replace the contents of "foo" with the uploaded body.  Alternatively,
"gemini://example.org/do/this text/javascript\r\n" might cause the
JavaScript in the uploaded body to be executed on the server.

As a special case, a client can send a Dioscuri header without a media type
or separating space, in which case no request body is allowed or expected.
This can be used if the contents of the URL are sufficient to tell the
server what to do.

=======

When Dioscuri has received the header and body, then it does whatever it
does and returns a regular Gemini header with some extensions.  If the
server is going to be conversational, it will process the uploaded body
with whatever semantics it assigns to it and then send a regular Gemini
response header.  For example, an application server might be sent a
header "<URL> application/json\r\n" followed by a JSON value, compute
something, and return "20 application/json\r\n" followed by the computed
JSON value.

If the server has nothing to send to the client, as in the case of an
upload, it can respond with "20\r\n", which means that there is no response
body.

=======

By mutual agreement between the client and the server, the server may
return "70 <URL>\r\n" not  followed by a body.  This code means that the
request has succeeded, but rather than the server sending a response body
in the same TCP connection, the response body can be found at <URL>.

A use case for this is that the client wishes to add a new file to a
container (directory or whatever) in the server but leaves it up to the
server to choose the new URL according to some algorithm (random,
timestamp, etc.)  So a request of "<container-URL> text/gemini\r\n"
followed by the body would in such a case respond "60 <object-URL>\r\n",
meaning that the new resource can be found at <object-URL>.

All other 2-digit response codes have the same meaning in Dioscuri as in
Germini.  The reason for not using the 30 code in place of 60 is that 30
would mean "redirect the request", as for all other cases of 30, whereas 60
means "the response can be found here."  I thought of using 21, but that
would make the second status digit an essential part of the protocol.  Note
that like 2x, 6x is considered a success.

=======

Finally, an implementation note: the TCP library used to implement Dioscuri
clients must be able to separately close the input and the output sides of
the TCP connection to the server.  So in the application server discussed
above, the client closes the output side of its socket when it has sent the
body, and the server receives EOF when it attempts to read more body.
However,  the input side on the client must remain open so that the
server's response can be read.

Comments?



John Cowan          http://vrici.lojban.org/~cowan        cowan at ccil.org
And it was said that ever after, if any man looked in that Stone,
unless he had a great strength of will to turn it to other purpose,
he saw only two aged hands withering in flame.   --"The Pyre of Denethor"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.orbitalfox.eu/archives/gemini/attachments/20200927/1020
e3cd/attachment.htm>

---

Next in thread (2 of 16): 🗣️ Meff (meff (a) meff.me)

View entire thread.