On Tue, 2002-02-05 at 20:06, Matt Feifarek wrote:
> I'm experimenting with non-html servlets. Based on code in XMLRPCServlet, I
> made this quick hack:
>
> ---------------------------
> from WebKit.Page import Page
>
> class gifpage(Page):
> def writeHTML(self):
> # get a bunch of data to send as image...
> file = open('d:\\apps\\gallery\\publish\\gfx\\logo.gif','rb')
> pic = file.read()
> file.close()
>
> # change the headers sent out by the httpd to reflect a new mimetype
> trans = self._transaction
> trans.response().setStatus(200, 'OK')
> trans.response().setHeader("Content-type", "image/gif")
> trans.response().setHeader("Content-length", str(len(pic)))
>
> # send the poop
> trans.response().write(pic)
> ---------------------------
>
> It works!
>
> Is there any reason that this is bad form? I'm concerned about low-level I/O
> issues and that sort of thing. I suppose that there's no reason to inherit
> from Page, when I could inherit from HTTPServlet. Opinions?
Well, you should do a loop on reading and flush it.
I believe this gives a good example:
http://webware.colorstudy.net/twiki/bin/view/Webware/FileStreamingAndContentDisposition
> If this is ok, we're planning to implement servlets that cough up flash and
> svg based graphs and that sort of thing. Heck, pdf, word, mp3, whatever
> should be possible. (I've also got an itch to re-write the mp3 server that I
> use [edna.sourceforge.net] in webware)
There's certainly nothing HTML-specific about Webware. There is perhaps
some performance issues, since the data gets handed about a bit more
than it would normally (though that shouldn't be a big deal for most
situations).
There's other tricks with local (or even remote) redirects that you can
do -- they'd perform better, and should be fine unless you want to
secure files.
Ian
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss