content-negotiation

mod_rewrite rules and content negotiation

I am relatively new to mod_rewrite, but have a site which I would like to have "pretty urls." Similarly to SO :). I am attempting to have things like: "http://www.whatever.com/search/test" get rewritten to "http://www.whatever.com/search.php?q=test" and have had some limited success. I believe that content negotiation is getting in my w...

How do I download a file with a non-HTML content type from within a browser?

I'm trying to use content negotiation to give both a HTML and a RDF/XML representation of a resource on a HTTP server. On the server side this works, i.e. curl -H "Accept: application/rdf+xml" http://localhost:8182/ontologies/1 will retrieve the correct version. I can also do the same with JavaScript/Dojo: function downloadOntologyRD...

Why does Apache Content Negotiation not with files that have a hyphen in the extension?

I am trying to use Apache Content negotiation for localizing my site. I have the files index.htm.en, index.htm.es, index.htm.zh-ch and index.htm.en-GB. Apache content negotiation is not working in the third and fourth case. So is this because of the hyphen(-) in the extension? ...

RESTful Content Negotiation in Rails

I'm looking to implement content negotiation on some resources in a Rails app. I'm using Mootools and will likely be able to tweak the content type accepted by an XMLHTTPRequest to "application/json". Is there any way to pick up on this information in my controller and generate JSON responses instead of XHTML? I'm trying to avoid doin...

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 types: text/data,application/x-data,application/data+xml Given that there are multiple MIME types possib...

Content negotiation ignored when using browser Back button

Here's the situation: I have a web application which response to a request for a list of resources, lets say: /items This is initially requested directly by the web browser by navigating to that path. The browser uses it's standard "Accept" header which includes "text/html" and my application notices this and returns the HTML content...

Is there an example on how to use Spring 3.0 content negotiation for RESTful services?

I was reading the Spring 3.0 Documentation and Blog Posts (followups) on how to create REST style services with Spring MVC but I can't find any working example on how to use the ContentNegotiatingViewResolver. I have a test controller like this @Controller public class IndexController implements Serializable { @RequestMapping("/inde...

How to redirect users based on browser language

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 t...

Content Negotiation on Tomcat

I'm trying to get my Tomcat to use pretty URLs, similar to Apache's MultiViews option. I tried using AJP to proxy Tomcat to Apache, but the .htaccess file is still ignored. What are my options for Tomcat? ...

Is there a C# or .NET class to handle HTTP Content Negotiation?

Is there a C# or .NET class to handle HTTP Content Negotiation with a User Agent? I would like to be able to supply a list of acceptable Content Types, and have those negotiated with the browser to find the best match. ...

How is the concept of "content negotiation" called outside the HTTP context?

Hello, everyone! 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 provider About the content: What I am very good at, is providing apples. I a...

Rest Content Negotiation and Caching

I'm wondering how caching works with content negotiation based API. Since the to get a resource in XML or JSON, the URI will be the same, for example: http://example.com/bikes/mountain The service returns JSON / XML based on the Accept type header. How smart are caches? For example: if one client requested this using Accept t...

Serving XHTML as application/xhtml+xml with Ruby on Rails

I'm trying to get my Rails app to serve XHTML content properly, with the correct content-type of application/xhtml+xml. Ideally with content negotiation so that IE users get a chance to use the site too. Given that all the HTML generated by Rails is marked at XHTML 1.0 Transitional, I'm a bit surprised that there is no obvious option to...

Specify supported media types when sending "415 unsupported media type"

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? ...

Grails Content Negotiation - handling unsupported type

Hi, We are using content negotiation in our service using the Accept header and the withFormat method....the issue we are facing is that we want to return a 406 http status if the Accept header has a type which is not supported by our service....can anybody give us some ideas on how would we go about doing this ? Thanks, VK ...