I posted a C# port of the mimeparse library to github:
http://github.com/mamund/mimeparse-csharp/tree/master
I included a simple console app that runs an example and kicks off
simple Debug.Assert code to run the tests.
My initial tests failed for the following cases:
// match using a subtype wildcard
Debug.Assert(MimeParse.BestMatch(mimeTypesSupported, "application/*;
q=1") == "application/xml");
// match using a type wildcard
Debug.Assert(MimeParse.BestMatch(mimeTypesSupported, "*/*") ==
"application/xml");
In both cases, my code returned the "application/xbel+xml" MIME-type.
I modified FitnessAndQuality.CompareTo(object x) method to solve this
problem:
if (this._fitness == faq._fitness)
{
if (this._quality == faq._quality)
{
rtn = string.Compare(this._mimeType, faq._mimeType, true); // sort
using the MimeType for ties
}
else
{
rtn = (this._quality < faq._quality ? -1 : 1);
}
}
else
{
rtn = (this._fitness < faq._fitness ? -1 : 1);
}
I suspect this is not correct. What are the selection rules that
govern cases where the */* type is the only one passed in the Accept
header?
Looking forward to any comments/questions.
MikeA