Content negotiation is a mechanism defined in the HTTP specification that makes it possible to serve different versions of a document (or more generally, a resource representation) at the same URI, so that user agents can specify which version fit their capabilities the best.
Questions tagged [content-negotiation]
184 questions
0
votes
1 answer
How is the concept of "content negotiation" called outside the HTTP context?
What are different terms for "content negotiation" (when not talking about HTTP)?
For example: some (remote or local) services, components, modules,
are negotiating about which protocol to use and/or which content type to exchange.
Service…

java.is.for.desktop
- 10,748
- 12
- 69
- 103
0
votes
2 answers
Web API 2.2 always returns JSON content
My simple Action method below always returns JSON, regardless of having Accept header set to application/xml. Content negotiation works fine on other actions I have in this same controller.
public HttpResponseMessage GetOrder(int id) {
var…

Mikee
- 1,571
- 2
- 14
- 24
0
votes
1 answer
HTTP Content Negotiation and the Range header
How does the Range header work with Content Negotiation? Let me explain, but first let's all agree to the following: HTTP is a stateless protocol.
When an HTTP Server is able to send multiple representation of a single resource, content negotiation…
user1040049
0
votes
1 answer
In MVC, how do I specify JSON serialization when not using ActionResult return types?
With ASP.NET MVC 5, you can skip the ugly "ActionResult" return type, and instead, specify a 'real' class. However, it seems that MVC wants to return the .ToString() version of my object as Content instead of the JSON serialized version of my object…

Timothy Khouri
- 31,315
- 21
- 88
- 128
0
votes
1 answer
In Express4, how to force a MIME type for negotiation
In Express 4, what's the best approach to forcing a particular MIME type to be used in a subsequent res.format(...) call?
Content negotiation works perfectly (when using curl and manual headers) but I'm in a browser where I want to force a PDF to…

Stuart Watt
- 5,242
- 2
- 24
- 31
0
votes
1 answer
How to write a simple content negotiation with apache
I would like to write a rules that says, whenever that resource is requested, if the content type is X return the file_x, if it is Y return file_Y
Can anyone help here ?
Many thanks,
-D-

MaatDeamon
- 9,532
- 9
- 60
- 127
0
votes
2 answers
NancyFx conneg returning 406 from IResponseProcessor except for text/html content type
I'm running Nancy on Microsoft.Owin.Host.IIS (Helios).
I'm trying to wire up conneg via IResponseProcessor to respond to an Accept header of text/plain, but it will only return 406.
I've tried multiple content types, and nothing works.... EXCEPT,…

daredev
- 428
- 5
- 7
0
votes
2 answers
Can Content Negotiation values be sent out of order?
I'm determining a user's language/locale from the Accept-Language header, and was wondering if they could ever be passed out of order. I've written a php sort function to make sure they are in descending order, but if it's unnecessary, I'd like to…

bearfriend
- 10,322
- 3
- 22
- 28
0
votes
1 answer
content negotiation - displaying images in firefox
I have a gallery of miniatures of images. After clicking on one of them, a full size equivalent opens in a new tab. Let's say I have many versions for the image .jpg,.gif and .png . How can I modify my file so that a proper (most wanted by the…

Simon
- 2,643
- 3
- 40
- 61
0
votes
2 answers
Spring 3.2.x: skip the controller method in case of 406 Not Acceptable
So, let's have this simple controller:
@Controller
public class MyController {
private static final Logger logger = LoggerFactory.getLogger(MyController.class);
@RequestMapping(value="/entities", method = RequestMethod.GET)
public…

Jan Dudek
- 245
- 1
- 5
- 8
0
votes
1 answer
Laravel 4 RESTful Api with content negotiation
I'm working in a RESTFul API with laravel, and I want to use content negotiation in my project, but I don't know how to accomplish that.
I have my controllers separted by api version, and I want to distinguish between api versions and use the…

ramdemon
- 97
- 1
- 8
0
votes
1 answer
Content Negotiation when looking at different output formats
I was doing some practice programming with spring mvc and I decided to do an example regarding content negotiation.
I started with a uri "/products":
When I ask for /products.json it returns me json, which I am happy about
When I ask for…

Shiraaz.M
- 3,073
- 2
- 24
- 40
0
votes
1 answer
BeanCreationException while creating an ContentNegotiatingViewResolver
I'm trying to make my Android app communicate with my Server, which is hosting my web application. For the Web side, I'm using Spring and everything was working fine. I could send data for database using spring and etc. But now, I'm trying to make…

Felipe Mosso
- 3,907
- 11
- 38
- 61
0
votes
2 answers
.NET MVC 4 Content Negotiation not working
I have a web service which is implemented in C# using .NET MVC 4, but for some reason they are always returning the data in XML format although I am sending an Accept: application/json header. Any ideas what could be wrong?
Thanks in advance
Update:…

rreyes1979
- 1,855
- 3
- 23
- 34
0
votes
1 answer
Canonical vs Requested Type in Content Negotation
So I was wondering what should be done with HTTP Content Negotiation regarding requests where the returned data may have multiple valid MIME types.
For example if say I have some arbitrary data that has the following possible MIME…

RobV
- 28,022
- 11
- 77
- 119