MIME-type magic hierarcy
Arnout Engelen
file at bzzt.net
Sun Sep 16 20:36:41 EEST 2007
Hi!
I was looking for a way to convince Apache to serve up MusicXML files,
which have the plain '.xml' extension, with the proper
'application/vnd.recordare.musicxml+xml' MIME type rather than the
generic 'application/xml'.
Because it's impossible to distinguish between a random xml file and a
MusicXML file, I turned to magic. It's a bit inelegant because I can't
predict at what offset the doctype will start:
# xml
0 string \<?xml application/xml
# musicxml
>38 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>39 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>40 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>41 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>42 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>43 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>44 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>45 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>46 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>47 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>48 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>49 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>50 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>51 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>52 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>53 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>54 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>55 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>56 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
>57 string \<\!DOCTYPE\040score
application/vnd.recordare.musicxml+xml
However, Apache will choke on this, because for a MusicXML file it will
yield both application/xml and application/vnd.recordare.musicxml+xml.
Is there another way to do this? Would there be anything fundamentally
wrong with adapting the software so that in case of multiple matches,
the last (most specific) one is chosen?
Arnout
More information about the File
mailing list