My webservice generates and returns a .tex-file. I want to give the correct mimetype in the http-header.
I didn't found so much except for here, where I find application/x-tex
. Is this an authority to stick to?
My webservice generates and returns a .tex-file. I want to give the correct mimetype in the http-header.
I didn't found so much except for here, where I find application/x-tex
. Is this an authority to stick to?
For those who came here... i ended up with
"application/x-tex"
Looking at /etc/mime.types
, I found:
MIME type | File extensions |
---|---|
application/x-latex |
latex |
text/x-tex |
tex , ltx , sty , cls |
Short answer: application/octet-stream
, because the IANA Media Type list does not have the .TeX file extension specified (NO application/x-tex
, etc, as mentioned), this will indicate to the browser that it is an "unknown" file and show a "Save As" dialog. See the Long answer for more information.
Long answer: Internet Assigned Numbers Authority (IANA) is responsible for the official Media Types list (formerly known as a MIME type) and I couldn't find any for .TeX extension, maybe because TeX is a software designed to format scientific documents (e.g. complex math formulae), not a common application, its a typesetting language (source code), the output is usually a PDF:
TeX source files can be typeset into several different output formats, depending on the engine. Notably, the pdfTeX engine (despite its name) can output both DVI and PDF files.
At a high level, the output format that gets used depends on the program you invoke. If you run latex (which implements the LaTeX format), you will get DVI; if you run pdflatex (which also implements the LaTeX format), you will get PDF.
No TeX engine implements native HTML output, but it is still possible to get HTML, XML, etc., output:
The tex4ht program can be run (e.g., htlatex, make4ht). TeX4ht uses TeX behind the scenes, so user macros, etc., are generally recognized. There are many possible output formats, including Office XML. TUGboat article on tex4ht, and more recent article. The lwarp LaTeX package causes LaTeX to output HTML5. It hooks into many packages to create the html. TUGboat article on lwarp. The LaTeXML Perl program independently parses LaTeX documents and generates many output formats.
Therefore, in the case of using .TeX engine as a PDF output, e.g., it should be used the application/pdf
. Although, my understanding of the original post is that the developer intends to return a .TeX-file from his web service. Thus, as the Media Types list does not specify any subtype to .TeX, the application/octet-stream
type would indicate to the browser that the file is "unknown" and propose a "Save As" dialog. Source: Media Types procedures - MDN Web Docs
application/octet-stream
would be easier. –
Armagh Content-Disposition
header was set to attachment, and propose a "Save As" dialog." because, as my understanding, there isn't a "proprietary file type" defined in the official Media Type list. Do you agree? –
Armagh application/octet-stream
the correct Media Type for this case, but the complete reasoning provides other forms of uses for the TeX engine because could be an output for a PDF file. –
Armagh © 2022 - 2024 — McMap. All rights reserved.