Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom headers impossible with XDomainRequest (IE8/9) #159

Closed
wants to merge 1 commit into from
Closed

Custom headers impossible with XDomainRequest (IE8/9) #159

wants to merge 1 commit into from

Conversation

nicolas-rempulski
Copy link
Contributor

XDomainRequest objects cannot be set with custom headers (especially content-type). XDomainRequest.contentType is a read-only field (getter) :

http://msdn.microsoft.com/en-us/library/ie/cc288060(v=vs.85).aspx

The reason behind this is security, as stated in this msdn blog entry (point 4) :

http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx.

But on xhr.js [getXMLHttpRequest] function, the decision between XDomainRequest and XmlHttpRequest do not check if the request parameters specify headers. So if inParam.headers is set with some custom headers, in a XDomain scenario, [request] function would try to set them with :

xhr.setRequestHeader(key, inParams.headers[key]);

But the function setRequestHeader is not defined for XDomainRequest objects.

Thus I propose to patch xhr.js in two points :

1)Passing all request params to [getXMLHttpRequest] to allow a fallback to XMLHttpRequest object in case inParams.headers are set.

2)Checking the definition of xhr.setRequestHeader before setting header, thus preventing an exception if the xhr variable is a XDomainRequest.

Enyo-DCO-1.0-Signed-off-by: Nicolas Rempulski nicolas.rempulski@ubidreams.com

Edit : sorry about this slip, yet I read the contribute page !

…tpRequest object when headers are specified.
@unwiredben
Copy link
Contributor

This looks good -- I just need a Enyo DCO in order to take the pull. See http://enyojs.com/community/contribute/ -- just provide it as an edit on the PR description.

@unwiredben
Copy link
Contributor

Since this doesn't merge directly anymore, I'm just incorporating the idea into my own code change and closing this pull request.

@unwiredben unwiredben closed this Nov 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants