java bestmatch

6 views
Skip to first unread message

Peter

unread,
Oct 18, 2011, 7:37:19 AM10/18/11
to Mimeparse-dev
Hi,

I have come across a case thanks to ie, which seems to baffle
bestMatch.

The url ends with ".xml", which seems to convince ie to send the
Accept header below. Really, since it is a browser, I would want to
serve text/html, but the negotiation process ends up at something
different, perhaps due to chance.

supported = "application/xml","application/atom+xml","text/
xml","application/json","text/html","application/opensearchdescription
+xml"
header = "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/
x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-
powerpoint, application/msword, application/x-ms-application,
application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml
+xml, */*"

bestMatch returns "application/opensearchdescription+xml", it would
seem because it is the last in the supported list.

I guess this would be ok if the client wasn't a browser, since I
haven't expressed the server's preference of what to serve. Should
that
be done by the order in which they are added to the supported
collection? What is the 'right' mime type to serve in this case.

Any comments appreciated.

Thanks,
Peter

mca

unread,
Oct 18, 2011, 10:26:16 AM10/18/11
to mimepa...@googlegroups.com
Peter:

in my server implementations, i often stub in some code that does this:

'if the client accept header has no preference (i.e. no quaility
scores) my code scans the returned for the server's "preferred" format
and, if that is one that is supported by the client, my server uses
that format for the response representation.

sometimes, i actually "rank" the server-supported formats in this way
to allow for more flexibility.

possibly re-arranging the actual order of your supported list (reverse
it?, put your favored format last?) will do the trick?

mca
http://amundsen.com/blog/
http://twitter.com@mamund
http://mamund.com/foaf.rdf#me

> --
> You received this message because you are subscribed to the Google Groups "Mimeparse-dev" group.
> To post to this group, send email to mimepa...@googlegroups.com.
> To unsubscribe from this group, send email to mimeparse-de...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mimeparse-dev?hl=en.
>
>

Rushforth, Peter

unread,
Oct 18, 2011, 10:30:02 AM10/18/11
to mimepa...@googlegroups.com
Thank you Mike. I will try to order the server preferences. They are being
ordered by a java hashset in some opaque way right now so I will add a server preference,
and sort descending on that.

Thanks
Peter

Reply all
Reply to author
Forward
0 new messages