Negotiator behavior on duplicate accept content-types
zeronone opened this issue · comments
What is the expected behavior if there are duplicate content-types inside the Accept header.
var n = Negotiator({ headers: { accept: "application/json, application/xml, application/json" } });
n.mediaTypes();
// [ 'application/json', 'application/xml', 'application/json' ]
n.mediaTypes(['application/json', 'application/xml']);
// ['application/xml', 'application/json']
n.mediaTypes(['application/*']);
// []
n.mediaTypes(['*/*']);
// []
Does the preference of application/json
decreases due to duplication? And the availableMediaTypes
given to the mediaTypes()
should be concrete concrete types?
Hi @zeronone, for the first question, I need to consult the specifications to determine what exactly the behavior should be.
For your question about the concrete types, yes, the server must supply concrete types, while it is the client that can supply wildcards. This is because a server will have a set of actual concrete things it can send back to a client, while a client can ask for various different types. The formulation of these algorithms is specified in various HTTP RFCs.