diff --git a/src/gopher.c b/src/gopher.c index 81a98448c..38e44f754 100644 --- a/src/gopher.c +++ b/src/gopher.c @@ -27,15 +27,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* TODO: - * - * - Replace "." with "," in documents to avoid early stop. - * - Allow to configure a gopher-hostname, so that it can be used as default - * for streams converted into listings. - * - If __gopher_header__ and/or __gopher_footer__ are defined, they are - * put before/after directory listings generated by streams. - * - Find useful ways to convert the other Redis types to gopher output. */ - #include "server.h" /* Emit an item in Gopher directory listing format: @@ -80,5 +71,27 @@ void processGopherRequest(client *c) { * will be flagged with CLIENT_CLOSE_AFTER_REPLY, in accordance with the * Gopher protocol. */ if (c->argc == 0) decrRefCount(keyname); - addReplyProto(c,".\r\n",3); + + /* Note that in theory we should terminate the Gopher request with + * "." (called Lastline in the RFC) like that: + * + * addReplyProto(c,".\r\n",3); + * + * However after examining the current clients landscape, it's probably + * going to do more harm than good for several reasons: + * + * 1. Clients should not have any issue with missing . as for + * specification, and in the real world indeed certain servers + * implementations never used to send the terminator. + * + * 2. Redis does not know if it's serving a text file or a binary file: + * at the same time clients will not remove the "." bytes at + * tne end when downloading a binary file from the server, so adding + * the "Lastline" terminator without knowing the content is just + * dangerous. + * + * 3. The utility gopher2redis.rb that we provide for Redis, and any + * other similar tool you may use as Gopher authoring system for + * Redis, can just add the "Lastline" when needed. + */ }