GithubHelp home page GithubHelp logo

Comments (6)

jasonmitchell avatar jasonmitchell commented on August 16, 2024

The specification for 406 (https://tools.ietf.org/html/rfc7231#section-6.5.6) says a payload with the available representations should be generated. Should Negotiate be generating this to follow the spec or is returning an empty body a pragmatic choice?

from carter.

jchannon avatar jchannon commented on August 16, 2024

I think it's the latter and the same approach we used in Nancy but didn't realise the server SHOULD return a payload.

I wonder if @darrelmiller has any opinion on this and what the body should look like

from carter.

jasonmitchell avatar jasonmitchell commented on August 16, 2024

Personally I'm fine with the empty body.

If it was to generate a body, implementation-wise I guess IResponseNegotiator might need to expose the content type it will generate in order to build a list of available respresentations?

from carter.

darrelmiller avatar darrelmiller commented on August 16, 2024

@jchannon
There was a draft proposal once upon a time that provided a way of describing the potential available variants, but I'm pretty sure it was all done in headers. I suspect this 406 body is based on the same dream of returning a body from a 300. However, until someone proposes a media type to do this and it gets some traction I think either an empty body, or some human readable HTML is the way to go.

On a related note. Do you give the option for the server to say "I don't care that you asked for X, I don't support X, so I'm giving you the default Y"? This is instead of doing 406.

from carter.

jchannon avatar jchannon commented on August 16, 2024

Yeah that's what it does now, if I can't find a way to negotiate the Accept header it returns a JSON representation. I know that it's ok to do that I just had a thought I wondered if 406 would be better. I'm in two minds 😄

from carter.

darrelmiller avatar darrelmiller commented on August 16, 2024

As a framework author, you get to have an opinion here. Do you pick one way, or do you make it configurable? The question is, what is a client going to do? You are either returning an error code, or a content type they claim they can't handle. The only upside to the second approach is a client can fallback to what a web browser does and say, would you like to save that to disk?

from carter.

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.