As you can see, Request.JSON sets the Accept/X-Request headers itself,
manually (i.e. they are not options):

https://github.com/mootools/mootools-core/blob/master/Source/Request/Request.JSON.js#L28

But any other headers you wish to set may be specified in the options.

Regardless, if your server responds with json data, even of the content type
is not application/json, the Request.JSON attempts to send that data through
JSON.decode and should work.

On Mon, Aug 8, 2011 at 10:14 AM, Lee <[email protected]> wrote:

> No ideas?  Should I file a bug report?
>
> On 04/08/2011 13:49, Lee wrote:
>
>> Thanks for your reply.
>>
>> Accept header relate to that which the client is able, and prefers, to
>> accept. The content-type header is used to describe the content of the
>> media entity being transmitted. You can see its use most plainly in
>> uploading images to a server.
>>
>> My problem is that a JSON request is being sent with a content-type
>> that describes an XML document, when no XML document is being sent. I
>> would like to override this, and it is not possible.
>>
>> I presume this originates with the HTTP XML Request object, but do not
>> know Mootools core to address the issue, so I thought I'd post here.
>>
>> Just to be clear, the problem has nothing to do with the server, which
>> is correctly responding to JSON.Request's declaration that it has sent
>> an HTTP request entity of with a media described by the content type
>> header of 'application/xml'.
>>
>> Thanks
>> lee
>>
>>
>> On Aug 4, 10:26 am, Arian Stolwijk<[email protected]>  wrote:
>>
>>> Content-Type is to serve data, your server should check the Accept and
>>> X-Request headers. If that's application/json it should return a response
>>> with the Content-Type as application/json too.
>>>
>>> In the Net tab of firebug or the Network tab of webkit inspector you can
>>> see
>>> the Request headers, which you set with the headers option, and the
>>> response
>>> headers, response content and more.
>>>
>>> On Thu, Aug 4, 2011 at 9:45 AM, Lee<[email protected]>  wrote:
>>>
>>>> Hello list,
>>>> new Request.JSON({
>>>>        url:            this.serverSideUri,
>>>>        method: 'OPTIONS',
>>>>        async:  true,
>>>>        emulation:      false
>>>> }).send();
>>>> Firebug doesn't tell me anything about this request, only the
>>>> response, which I am generating.
>>>> Problem seems to be that my server (Apache 2) sees the request's
>>>> content-type headers as application/xml.
>>>> I have tried adding content-type headers to the request, to no avail -
>>>> it would be good for me, at least, if any parameter I pass Request
>>>> clases overrode those the class itself defines for the request.
>>>>        // All ineffective:
>>>>        headers:        {
>>>>                'content-type' : 'application/json',
>>>>                'contentType' : 'application/json',
>>>>                'Content-Type' : 'application/json',
>>>>        }
>>>> Do you want me to post this somewhere else?
>>>> Thanks
>>>> Lee
>>>>
>>>

Reply via email to