Hi Andrei,

> regardless I called (mime), and browser refuses to display the image.
> Is that because (mime) call only applied while processing svgtest.l file  
> (i.e GET request), not while processing GET test.svg ?

Ah, OK. I see two problems:

1. The proper way is to call

> (mime "svg" "image/svg+xml" 1)

once, in the beginning of the program. I usually install such additional
mime types soon after loading the libraries:

   (load .. "lib/http.l" ..)
   (mime "svg" "image/svg+xml" 1)

BUT: This only makes sense, if then a static file with the extension
".svg" is supposed to be passed to the browser. The function 'http' uses
the '*Mimes' global to decide which Content-Type to put into the HTTP

2. In your case, where you create the SVG code dynamically in a file
   with the extension ".l", the global '*Mimes' is not used, because
   '.l' files are passed to Lisp for execution. Then the Lisp code takes
   care of producing the right HTTP header.

So your code in "svgtest.l" must output the correct header. As you call
the function 'html':

> (html NIL "SVG test" "lib.css" NIL (here 'EOF) (<p> NIL (print *Mimes)))

It will generate a header with the type "text/html; charset=utf-8",
which is not what you intend.

Thus, what you would need is something like

   (httpHead "image/svg+xml")
   (ht:Out *Chunked
      (prinl "<object data=\"test.svg\" width=\"400\" height=\"400\"/>")
      (prinl ".. more svg code ..") )

Does this work?

- Alex

Reply via email to