content-negotiation

localisation in RESTful services

六眼飞鱼酱① 提交于 2021-02-08 06:45:55
问题 I have a RESTful service that returns an enum. I was pondering whether to return integers or strings for an enum value, when it occurred to me that returning a string would depend on the locale of the client. So how should you handle localisation in REST? Is locale part of conneg? 回答1: Localisation is part of content negotiation, and language preferences are specified using the Accept-Language header (RFC). The RFC is quite strict about what the service is allowed to return here — for

Strange behavior of content negotiation concerning SPARQL CONSTRUCT query

我的梦境 提交于 2021-01-29 08:28:40
问题 When issuing a SPARQL CONSTRUCT query to a specific endpoint, Apache Jena library 3.14.0 issues an error message as follows. Endpoint returned Content Type: application/sparql-results+xml which is not a valid RDF syntax The code I wrote is as follows. QueryEngineHTTP qeh = new QueryEngineHTTP(endpointUrl, rq); qeh.setAcceptHeader("application/rdf+xml"); Model m = qeh.execConstruct(); The endpoint is https://id.nlm.nih.gov/mesh/sparql . The query is as follows. CONSTRUCT {?s <http://id.nlm.nih

What should be the return type of WEB API Action Method?

纵饮孤独 提交于 2020-08-22 04:45:00
问题 I am developing ASP.NET Web API using .NET Core. This Web API is going to be mainly accessed by UI application (UI will be developed using ASP.NET Core MVC) but in future API may be accessed by other applications as well. In my WEB API all methods are async. If I want client to do content negotiation then what should be the return type of the API action method Task<IActionresult> or Task<SomePOCO> If I want method to always return data in JSON format then what should be return type of the API

What should be the return type of WEB API Action Method?

試著忘記壹切 提交于 2020-08-22 04:44:30
问题 I am developing ASP.NET Web API using .NET Core. This Web API is going to be mainly accessed by UI application (UI will be developed using ASP.NET Core MVC) but in future API may be accessed by other applications as well. In my WEB API all methods are async. If I want client to do content negotiation then what should be the return type of the API action method Task<IActionresult> or Task<SomePOCO> If I want method to always return data in JSON format then what should be return type of the API

What should be the return type of WEB API Action Method?

佐手、 提交于 2020-08-22 04:44:10
问题 I am developing ASP.NET Web API using .NET Core. This Web API is going to be mainly accessed by UI application (UI will be developed using ASP.NET Core MVC) but in future API may be accessed by other applications as well. In my WEB API all methods are async. If I want client to do content negotiation then what should be the return type of the API action method Task<IActionresult> or Task<SomePOCO> If I want method to always return data in JSON format then what should be return type of the API

How to set the default content type in Spring MVC in no Accept header is provided?

五迷三道 提交于 2020-06-24 05:44:07
问题 If a request is sent to my API without an Accept header, I want to make JSON the default format. I have two methods in my controller, one for XML and one for JSON: @RequestMapping(method = RequestMethod.GET,produces=MediaType.APPLICATION_ATOM_XML_VALUE) @ResponseBody public ResponseEntity<SearchResultResource> getXmlData(final HttpServletRequest request) { //get data, set XML content type in header. } @RequestMapping(method = RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE)

How to redirect users based on browser language

半世苍凉 提交于 2020-01-22 20:48:50
问题 I want to redirect users based on browser language, I figured out how to do this here, it works fine, here is the code(PHP): if(preg_match('/en-US/', $_SERVER['HTTP_USER_AGENT'])) header("location:index.php"); else header("location:http://cn.gearor.com"); The problem is I only want to redirect users from other websites or at the first visit to my website. Which means I don't want users reading some pages of my website, when they go back to index, they were redirect to other page. And I also

How to redirect users based on browser language

给你一囗甜甜゛ 提交于 2020-01-22 20:47:09
问题 I want to redirect users based on browser language, I figured out how to do this here, it works fine, here is the code(PHP): if(preg_match('/en-US/', $_SERVER['HTTP_USER_AGENT'])) header("location:index.php"); else header("location:http://cn.gearor.com"); The problem is I only want to redirect users from other websites or at the first visit to my website. Which means I don't want users reading some pages of my website, when they go back to index, they were redirect to other page. And I also

Wikidata content negotiation

瘦欲@ 提交于 2020-01-22 00:49:38
问题 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. 回答1: 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,

HTTP Accept Header meaning

谁说我不能喝 提交于 2019-12-29 03:25:07
问题 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. 回答1: No, if the