Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negotiator behavior on duplicate accept content-types #48

Open
zeronone opened this issue Jun 24, 2016 · 1 comment
Open

Negotiator behavior on duplicate accept content-types #48

zeronone opened this issue Jun 24, 2016 · 1 comment
Assignees

Comments

@zeronone
Copy link

zeronone commented Jun 24, 2016

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?

@dougwilson
Copy link
Contributor

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.

@dougwilson dougwilson self-assigned this Jun 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants