Bob Techentin
2005-08-17 14:06:13 UTC
I am restructuring an application for starkit deployment. (Yea! Cool!)
The online help is HTML files in the doc directory, and I wrote a little
code based on "Invoking Browsers" (http://wiki.tcl.tk/557) to launch a web
browser to display the files. Once I wrap everything into the starkit, the
browsers won't be able to see the doc files. I could embed one of the help
browsers (http://wiki.tcl.tk/3196), but they're a little limited in both
graphics formats and printing.
One solution is to integrate a web server into my Tcl application, fire up a
browser, and pass it a URL to a localhost socket. I tried dropping tclhttpd
into the starkit library (http://wiki.tcl.tk/2085) but it is quite large,
and apparently more complex than [package require tclhttpd]. So my next
stop was the Dust Mote http server (http://wiki.tcl.tk/4333) which is about
30 lines of Tcl. Very cool.
The Dust Mote server responds to requests by returning a header line
(HTTP/1.0 200 OK), followed by a blank line, followed by the contents of the
file. This worked great until I tried the 'back' and 'refresh' buttons on
MS Internet Explorer. Suddenly all the pages were rendered as HTML source.
I found out, through trial and error, that IE really wants a content type
header line, so I added
if { [file extension $file] eq ".html" } {
puts $socket "Content-Type: text/html"
}
and everything seems to work. But I'm still left wondering if there is more
that I should be generating for the header. I looked at the tclhttpd code,
and find lots of mime type handling, and some things that might go into an
http header, but I'm not sure what I really need. Can anybody make
suggestions or point me to a little light reading?
Thanks,
Bob
The online help is HTML files in the doc directory, and I wrote a little
code based on "Invoking Browsers" (http://wiki.tcl.tk/557) to launch a web
browser to display the files. Once I wrap everything into the starkit, the
browsers won't be able to see the doc files. I could embed one of the help
browsers (http://wiki.tcl.tk/3196), but they're a little limited in both
graphics formats and printing.
One solution is to integrate a web server into my Tcl application, fire up a
browser, and pass it a URL to a localhost socket. I tried dropping tclhttpd
into the starkit library (http://wiki.tcl.tk/2085) but it is quite large,
and apparently more complex than [package require tclhttpd]. So my next
stop was the Dust Mote http server (http://wiki.tcl.tk/4333) which is about
30 lines of Tcl. Very cool.
The Dust Mote server responds to requests by returning a header line
(HTTP/1.0 200 OK), followed by a blank line, followed by the contents of the
file. This worked great until I tried the 'back' and 'refresh' buttons on
MS Internet Explorer. Suddenly all the pages were rendered as HTML source.
I found out, through trial and error, that IE really wants a content type
header line, so I added
if { [file extension $file] eq ".html" } {
puts $socket "Content-Type: text/html"
}
and everything seems to work. But I'm still left wondering if there is more
that I should be generating for the header. I looked at the tclhttpd code,
and find lots of mime type handling, and some things that might go into an
http header, but I'm not sure what I really need. Can anybody make
suggestions or point me to a little light reading?
Thanks,
Bob
--
Bob Techentin ***@NOSPAMmayo.edu
Mayo Foundation (507) 538-5495
200 First St. SW FAX (507) 284-9171
Rochester MN, 55901 USA http://www.mayo.edu/sppdg/
Bob Techentin ***@NOSPAMmayo.edu
Mayo Foundation (507) 538-5495
200 First St. SW FAX (507) 284-9171
Rochester MN, 55901 USA http://www.mayo.edu/sppdg/