content-negotiation

Wikidata content negotiation

倾然丶 夕夏残阳落幕 提交于 2019-12-02 05:42:31
I was wondering why Wikidata content negotiation results with more than one entities in the file. For instance P2044 in the browser http://www.wikidata.org/entity/P2044.nt gives me triples also about Q6452016 entity: http://www.wikidata.org/entity/Q6452016 I would expect either triples about P2044 or document metadata. Thanks in advance. There are many options of what to produce in an RDF output (as well as there is no standard on what to return in a DESCRIBE query result). In Wikidata, you can use one of these options documented here . See also RDF Dump Format about the Wikidata data model.

Specify supported media types when sending “415 unsupported media type”

蹲街弑〆低调 提交于 2019-12-01 02:56:43
If a clients sends data in an unsupported media type to a HTTP server, the server answers with status " 415 unsupported media type ". But how to tell the client what media types are supported? Is there a standard or at least a recommended way to do so? Or would it just be written to the response body as text? There is no specification at all for what to do in this case, so expect implementations to be all over the place. (What would be sensible would be if the server's response included something like an Accept: header since that has pretty much the right semantics, if currently in the wrong

How to configure custom MediaType in Spring MVC?

ぐ巨炮叔叔 提交于 2019-11-29 13:54:01
Using Spring MVC, I have controllers already working for both JSON and XML media formats. In the content negotiation configuration, I would like to rely on Accept header only, and introduce a custom name media type, for example: "myXml" My configuration: @Configuration @EnableWebMvc public class WebConfig extends WebMvcConfigurerAdapter { @Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer .favorPathExtension(false) .favorParameter(false) .ignoreAcceptHeader(false) .useJaf(false) .mediaType(MediaType.APPLICATION_JSON_VALUE, MediaType

How to get a response from the Nancy Negotiator?

不羁的心 提交于 2019-11-29 10:32:36
问题 I have a NancyContext and I need to get a Response with a body based on the correct content negotiator for the request. I think I can use Nancy's Negotiator class to add a model, set the status, and other things. But then, I need to return a subtype of Response . So, what can I use to build the response using the Negotiator ? Here's my method: public Response ConvertToHttpResponse(Exception exception, NancyContext context) { var negotiator = new Negotiator(context) .WithStatusCode

HTTP content negotiation conflicts in JAX-RS/Jersey?

可紊 提交于 2019-11-29 00:13:11
I am enjoying the auto HTTP content negotiation of JAX-RS (specifically Jersey), i.e. its ability to route my resources by "Accept" and/or "Content-Type" headers. But I'm finding that sometimes it doesn't give me enough control when there is a conflict. For example, consider the following endpoints: @Path("/order") public class OrderController { @GET @Path("{orderID: \\d+}") @Produces("text/html") public View getOrderView(@PathParam("orderID") long id) { Order order = this.getOrderData(id); return new OrderView(order); } @GET @Path("{orderID: \\d+}") @Produces({"application/json", "application

HTTP Accept Header meaning

强颜欢笑 提交于 2019-11-28 18:34:06
When a browser's Accept request header says something like the following: Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Does that mean that application/xml , application/xhtml+xml , and text/html all have a quality param of 0.9 ? Or does it mean that application/xml and application/xhtml+xml have the default ( q=1 ) and text/html has the q=0.9 param? I'm assuming the former, but was hoping someone knew more definitively. No, if the quality parameter is missing q=1.0 is assumed: Each media-range MAY be followed by one or more accept-params,

How to configure custom MediaType in Spring MVC?

一个人想着一个人 提交于 2019-11-28 03:54:00
问题 Using Spring MVC, I have controllers already working for both JSON and XML media formats. In the content negotiation configuration, I would like to rely on Accept header only, and introduce a custom name media type, for example: "myXml" My configuration: @Configuration @EnableWebMvc public class WebConfig extends WebMvcConfigurerAdapter { @Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer .favorPathExtension(false) .favorParameter(false)

HTTP content negotiation conflicts in JAX-RS/Jersey?

谁都会走 提交于 2019-11-27 14:10:06
问题 I am enjoying the auto HTTP content negotiation of JAX-RS (specifically Jersey), i.e. its ability to route my resources by "Accept" and/or "Content-Type" headers. But I'm finding that sometimes it doesn't give me enough control when there is a conflict. For example, consider the following endpoints: @Path("/order") public class OrderController { @GET @Path("{orderID: \\d+}") @Produces("text/html") public View getOrderView(@PathParam("orderID") long id) { Order order = this.getOrderData(id);