Question
Timothy Leavitt · Apr 25, 2022

Serving .woff/.woff2 over CSP

I have a .woff2 file I'm trying to serve over CSP.

If I set:
^%SYS("CSP","DefaultFileCharset")="UTF8"

Then it "just works" - but I'd rather not do something so heavy-handed/instance-wide, on principle. (This is for something that will ultimately be published on the Open Exchange.)

A more granular option, it seems, is described in the %CSP.StreamServer class reference:

if you need to define settings per extension (in uppercase) you can use ^%SYS("CSP","MimeFileClassify",$zcvt(ext,"U"))=$listbuild(type,bin,charset) where:

  1. type - Content Type value, e.g. 'text/javascript'
  2. bin - 1 if this is binary and 0 if this is a character file
  3. charset - For character files the charset to report in the charset header

If nothing is defined then for character files we use the default charset associated with the file device in InterSystems IRIS.

However, I can't seem to get this to work with any combination of settings. (I see the charset in the content-type header but the file is still mangled.)

Has anyone else solved this problem before?

0
0 146
Discussion (2)2
Log in or sign up to continue

It is very strange that the mechanism ^%SYS("CSP", "MimeFileClassify") does not work for you.

According to the sources of %CSP.StreamServer, it can be seen that all the work takes place in the FileClassify method, where ^%SYS("CSP", "MimeFileClassify") is also used.

I used ZEN on Caché and all was fine.

Can you give a simple CSP example to reproduce your situation?

Turns out the problem was *not* the woff files at all - it was the CSS file that used the font. Solution was:

set ^%SYS("CSP","MimeFileClassify","CSS")=$lb("text/css",0,"utf-8")