~sircmpwn/sr.ht-discuss

2 2

Gemini hosting mimetypes

Details
Message ID
<82d0cbd25ffeaf960370e2b7044fc4f2@andreafeletto.com>
DKIM signature
pass
Download raw message
Hi,
I host a gemini capsule here on sourcehut. The source code is made
available directly in the capsule thanks to gmnigit [0].
This tool adds a `.txt` extension to every file in the source tree,
since these files are obviously not supposed to be rendered as gemtext.
The problem is that sourcehut serves every file with `text/gemini`
mimetype, regardless of the extension.
Is this a missing feature or should it stay like that?

Thanks,
Andrea

[0]: https://sr.ht/~kornellapacz/gmnigit/
Details
Message ID
<CAVDX63BLGR7.WL0GKB29NN7I@nitro>
In-Reply-To
<82d0cbd25ffeaf960370e2b7044fc4f2@andreafeletto.com> (view parent)
DKIM signature
pass
Download raw message
This seems to happen because the ".txt" mimetype is not registered, and
so the mimetype detection fails. I'm not sure what the solution here
should be. Perhaps we should use the mimetype "application/octet-stream"
if detecting the mimetype by extension fails, and also make sure that
more mimetypes are registered.

In more concrete terms: this happens because mime.TypeByExtension
returns an empty string for unknown mimetypes. The go-gemini library
then thinks that no mimetype has been set and uses a default of
text/gemini.
Details
Message ID
<2a0d794dbe16c1c8e5982a742831edf5@andreafeletto.com>
In-Reply-To
<CAVDX63BLGR7.WL0GKB29NN7I@nitro> (view parent)
DKIM signature
pass
Download raw message
> This seems to happen because the ".txt" mimetype is not registered, and
> so the mimetype detection fails. I'm not sure what the solution here
> should be. Perhaps we should use the mimetype "application/octet-stream"
> if detecting the mimetype by extension fails, and also make sure that
> more mimetypes are registered.
> 
> In more concrete terms: this happens because mime.TypeByExtension
> returns an empty string for unknown mimetypes.

The database for the mimetypes can be configured at build-time and
defaults to /etc/mime.types which in my system (archlinux) has the
record for txt.
So either the mime.types file in the system used by sr.ht pages is
different, or a different database is used.

> The go-gemini library then thinks that no mimetype has been set and uses
> a default of text/gemini.

I think this is a sensible behavior, especially for files without an
extension.
Reply to thread Export thread (mbox)