GithubHelp home page GithubHelp logo

Comments (5)

jdeerhake avatar jdeerhake commented on July 19, 2024

I looked at this a little, but it's hard to wrap my head around the use of these params. The RFC is pretty vague about exactly how they should be used and matched against.

Searching around for content negotiation doesn't yield much information about them either. The best reference I could find are these apache docs which seem to indicate that when apache does content negotiation it only even bothers to look for a level param? The RFC says there can be multiple media range params, but it too only uses level in the examples.

I'm not really sure what should happen when there are multiple params, or whether q values should take precedence over specificity of the params?

from negotiator.

federomero avatar federomero commented on July 19, 2024

Thank you @therigu and @jdeerhake.

First of all, I think this discussion is pretty theoretic because I believe these params have no real practical use (please correct me if I'm wrong).

That being said, I agree with @therigu that negotiator is not handling this case correctly. I'm not 100% convinced how it handle it though. Consider the following cases:

Let's say we have Accept: text/html;attribute=value.
Is text/html an acceptable media type? What about text/html;attribute=other?

I think strictly speaking, it should probably reject both. But maybe it's preferable to accept the first one, or maybe both. I can't really find anything on the RFC that indicates which is the right solution.

What do you guys think?

Regarding specificity vs. q value, I think specificity takes precedence.

from negotiator.

jdeerhake avatar jdeerhake commented on July 19, 2024

I tend to think that as long as they don't have the same attribute with conflicting values, then it's a match. The RFC makes it clear that if we had Accept: text/html then text/html;level=3 would be an acceptable response, so it makes sense to me that the reverse would be true.

I started to refactor it to function like that and kinda ended up rewriting the whole file. https://github.com/jdeerhake/negotiator/commit/a1e142bd81d3d91782664e0ca9131f63f8d99939

from negotiator.

federomero avatar federomero commented on July 19, 2024

I don't think the reverse necessary holds. Saying Accept: text/html is like saying I want a car and Accept: text/html;level=3 is like saying I want a red car. It makes sense to me that if you ask for a car, a red car would be an acceptable response, but not the other way around.

from negotiator.

federomero avatar federomero commented on July 19, 2024

I ended up handling this strictly since I think that most consistent with how content negotiation works in general.

This commit 334105a takes care of that.

Thanks

from negotiator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.