Printing in a browser-fronted environment

Brian K. White brian at aljex.com
Fri Mar 31 13:15:05 PDT 2017


Content-type may be set a couple different ways.

If the file is being served by a cgi, the a cgi may write whatever kind 
of http headers it wants, including content-type.

If the file is being served by the web server directly, then you can 
define new custom content types in the mime-types file, or by special 
httpd.conf directives, (which probably means .htaccess directives can do 
it also)

But for the sake of simplicity I'll show the two most common/basic ways 
to get a mime-type set

A) cgi. In place of a plain url to a file, you have a url to a cgi 
script that squirts a file at the client.

The cgi might look like this:
...cgi-bin/login.vnc:
---
#!/bin/ksh
printf "Content-Type: VncViewer/Config\n\n"
# [...]
cat ${TEMPLATE}.vnc
printf "host=%s\r\n" $HOST
printf "port=%s\r\n" $PORT
---

The only http header in this case is "Content-Type: VncViewer/Config".
http header is nothing more than whatever lines are first emitted by the 
script (any script, any number of lines) until the first empty line. 
Everything after the first empty line is the content. So the 2nd "\n" on 
the printf makes the empty line which ends the headers and starts the 
content.


B) mime-types. Alternatively, the web server can be told to recognize 
files by their filename extensions, and send a specified content-type 
matched to a file extension. They are defined in mime-types, which might 
appear in a few different common places on the server depending on the 
servers apache config. (Other web servers like nginx will have some 
equivalent but I don't know their details)

So for instance on my opensuse boxes, the file is in /etc/mime-types, 
and I have these lines added to the end:
VncViewer/Config vnc
application/facetwin fwt
application/mstsc rdp
application/vnd.aljex.at at

There is VncViewer/Config again. If I had a static foo.vnc file sitting 
on the server and had a url to it, there is no cgi shell script to write 
headers. The web server itself generates a few http headers for the 
response when it sends the requested file, and this tells the web server 
to use VncViewer/Config instead of text/plain or 
application/octet-stream for any *.vnc files.

C) I'm pretty sure there are yet other ways you could define the 
behavior you want even more specially by httpd.conf and .htaccess rules, 
but I just don't happen to know those details off hand.

The CLIENT OS can also recognize a file by it's extension even if the 
web server doesn't send the right content-type, but that is unreliable. 
That is why you sometimes get .csv files that show up as text in the 
browser instead of downloaded and opened by your default spreadsheet 
app, or sometimes for example it works in IE but not in Firefox, for the 
same file from the same server to the same client.

-- 
bkw


On 3/31/2017 1:24 PM, Bob Rasmussen via Filepro-list wrote:
> On Fri, 31 Mar 2017, Kenneth Brody wrote:
>
>> Is it possible to have a new "Content-Type", such as
>> "application/X-PrintWizard", which could be returned as the result of
>> a "normal" HTTP link?
>
> I don't know. I believe the content-type is determined by the web
> server, but I don't know how it does so. Do you know this?
>
>
>
> Regards,
> ....Bob Rasmussen,   President,   Rasmussen Software, Inc.
>
> personal e-mail: ras at anzio.com
>  company e-mail: rsi at anzio.com
>           voice: (US) 503-624-0360 (9:00-6:00 Pacific Time)
>             fax: (US) 503-624-0760
>             web: http://www.anzio.com
>  street address: Rasmussen Software, Inc.
>                  10240 SW Nimbus, Suite L9
>                  Portland, OR  97223  USA
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> Subscribe/Unsubscribe/Subscription Changes
> http://mailman.celestial.com/mailman/listinfo/filepro-list
>



More information about the Filepro-list mailing list