Giter VIP home page Giter VIP logo

Comments (6)

glassfishrobot avatar glassfishrobot commented on July 26, 2024

Reported by [email protected]

from jersey.

glassfishrobot avatar glassfishrobot commented on July 26, 2024

[email protected] said:
It is possible to return a response without setting the media type and the
runtime should do the acceptable processing. So if you want to return an error
in a form that is acceptable to the client you can do the following:

@get
@ProduceMime(

{"appliction/xml", "application/json"})
public Response get() { JAXBBean b = new JAXBBean("content"); return Response.status(400).entity(b).build(); }

However! there is a bug when doing the following:

@get
@ProduceMime({"appliction/xml", "application/json"}

)
public Response get()

{ JAXBBean b = new JAXBBean("content"); throw new WebApplicationException( Response.status(400).entity(b).build()); }

The client accept header is ignored. So i need to fix that.

It is also possible to do acceptable processing using the:

Request.selectVariant

but i recommend this only for the case when the developer needs to handle wild
cards or cannot declare the supported media types statically.

IMHO returning an error using 200 (OK) is not the recommended thing to do from a
RESTful perspective. The HTTP error status should be used for error reporting
where appropriate. Using 200 (OK) to report errors limits the uniformity of the
interface and increases the coupling between the client and server.

from jersey.

glassfishrobot avatar glassfishrobot commented on July 26, 2024

[email protected] said:
Where possible the content type will ascertained from the accept header and the
matching message body reader associated with the entity of the
WebApplicationException.

from jersey.

glassfishrobot avatar glassfishrobot commented on July 26, 2024

Was assigned to jersey-issues

from jersey.

glassfishrobot avatar glassfishrobot commented on July 26, 2024

This issue was imported from java.net JIRA JERSEY-37

from jersey.

glassfishrobot avatar glassfishrobot commented on July 26, 2024

Marked as fixed on Monday, June 16th 2008, 7:44:27 pm

from jersey.

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.