Giter Club home page Giter Club logo

Comments (5)

wojcikstefan avatar wojcikstefan commented on June 30, 2024 1

Hi @marcinn , sorry for the delay. Yup, that quote is spot on and I think this package should respect that rule.

I think the change I proposed in #26 is the right step forward. It doesn't break any of the previously existing unit tests and - prior to the change - the behavior for using qvalue server-side was simply undefined. Now, we're defining it according to the RFC.

from python-mimeparse.

marcinn avatar marcinn commented on June 30, 2024 1

Thanks @wojcikstefan! Sorry for late response. I missed your reply. Best regards!

from python-mimeparse.

wojcikstefan avatar wojcikstefan commented on June 30, 2024

Hi @marcinn ! Typically the quality is specified on the types the client accepts and not the server's acceptable types. I haven't seen something like this before. Can you point me to some resource (e.g. a section in the RFC) where this behavior is described?

I preemptively implemented #26 in case we agree to do it in the way you described.

from python-mimeparse.

marcinn avatar marcinn commented on June 30, 2024

I've just saw that RFC7231 section 5.3.1 contains a phrase which describes what I'm doing:

This weight is referred to as a "quality value" (or "qvalue") because the same parameter name is often used within server configurations to assign a weight to the relative quality of the various representations that can be selected for a resource.

I'm creating a server which should serve a best matching and preferred representation. When client accepts anything (*/*), the server should respond with most-common/preferred mediatype. My implementation is based on mimeparse.best_match(). I'm passing acceptable media types and the client's header as arguments, but the function fails in that case.

I've declared a qvalue for a server's accetable types in a similar way how @Produces annotation work (please look at this), but using q instead of qs believing that mimeparse will do such matching automatically. But it didn't.

I realize that mimeparse.best_match() is written mostly for client's content matching and I can rewrite media type negotiation without using mimeparse, of course, but I'm also wondering about implementing it inside exisitng package - it is designed to do such things, I think. That's why I'm asking.

Looking at your patch I can just say that "the fix" is quite simple, but it is related to quality_and_fitness_parsed(). So it affects not only best_match(), but also quality_parsed().

Your patch works for me, but it may break compatibility for others (in cases where clients are not sending Accept header or asking server for anything). Is this a good idea? I don't know...

from python-mimeparse.

wojcikstefan avatar wojcikstefan commented on June 30, 2024

v1.6.0 released

from python-mimeparse.

Related Issues (14)

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.