JeroenWyseur JeroenWyseur - 1 year ago 98
reST (reStructuredText) Question

Can I change the headers of the HTTP request sent by the browser?

I'm looking into a restful design and would like to use the HTTP methods (

, ...) and HTTP headers as much as possible. I already found out that the HTTP methods
are not supported from the browser.

Now I'm looking to get different representations of the same resource and would like to do this by changing the
header of the request. Depending on this
header, the server can serve a different view on the same resource.

Problem is that I didn't find a way to tell my browser to change this header.

tag has a type attribute, that can have a mime type, looked like a good candidate but the header was still the browser default (in Firefox it can be changed in
with the

Answer Source

I don't think it's possible to do it in the way you are trying to do it.

Indication of the accepted data format is usually done through adding the extension to the resource name. So, if you have resource like


and GET /resources/resource returns its HTML representation, to indicate that you want its XML representation instead, you can use following pattern:


You have to do the accepted content type determination magic on the server side, then.

Or use Javascript as James suggests.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download