I’m talking with @baschdel on Mastodon about a possible extension to Gemini that would allow us to return to the read-write web. So how about a protocol variant via the scheme?
gemini+write://alexschroeder.ch/Test → an attempt to write the resource that would be served by requesting
gemini://alexschroeder.ch/Test – and we’d like to indicate a MIME type of the data and length (important because the server can’t tell when an upload is finished unless we mandate a timeout). How about simply sending that along on separate lines?
(And, as suggested by deshipu in the comments below, an authorization token!)
My goal, as always, is to make this work from the command line first. Here’s how it might work:
(sleep 1 \ && echo "gemini+write://alexschroeder.ch/Test" \ && echo "hallo" \ && file --brief --mime-type test.txt \ && wc --bytes < test.txt \ && cat test.txt) \ | nc alexschroeder.ch 1965
If the server doesn’t accept uploads, it can close the connection after discovering the scheme “gemini+write”, or when it discovers an unsupported MIME-type, or when it discovers that the size of the upload exceeds its own restrictions.
The status code 59 seems to be appropriate for any such refusals. A super well-behaved client might then peek at the socket and see whether any error message is forthcoming before sending the whole file... And if they they’re not waiting like in my command-line example above, then no harm done: the client is simply going to get a write error on the socket as the server drops the connection after sending the error message.
At first I thought that if the server accepts the upload and saves the data, a new OK status code would be nice to have. Something like 29 CREATED (the equivalent of the HTTP status code 201, perhaps). But when I implemented a client for Gemini+Write, I realized that a simple redirect on a successful save is good enough. There is no need for a “created” status 🙂
As you can see in the comments, Baschdel has different suggestion. His most important objection, as far as I can tell, are the missing codes. He would like the server to indicate whether it allows uploads or not, whether the MIME type is supported or not, whether the size exceeds some limit or not, and so on. There’s a lot more info on the page Baschdels spin on Gemini uploading.