💾 Archived View for envs.net › ~juhani › minigem › 20200709-socket-termination.gmi captured on 2024-06-16 at 12:34:21. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2020-10-31)
-=-=-=-=-=-=-
2020-07-09
Created a scrappy UI, with TextField for entering url, and a Text widget to dump the content to. While testing with live sites, I noticed that some sites worked fine and some halted without returning content. Closer investigation revealed that the content was returned, but the socket was not closed by the server. Or at least my client didn't notice if it was closed. To make the client more robust, I refactored it so that it doesn't depend on server to close the socket. Socket data events are transformed to a byte stream that is consumed just enough to parse header, and the remaining stream is returned as the response body. A timeout is set on the stream to close the socket if the server fails to do it.
https://git.envs.net/juhani/minigem/commit/ecd4e3a896527d06275a5f21453ca06125d29af3
But this solves the problem only partially. Now the client can parse the header, but doesn't know if it has the whole response until the socket is terminated. It's workable as long as the payload has delimiters, eg. lines, but how about images.