-
Notifications
You must be signed in to change notification settings - Fork 146
Requests with credentials (add withCredentials to xhr) #40
Comments
Right now there is no way to do what you're trying to do with rest.js. Although, it's easy enough to copy the It's worth noting that only XHR2 compatible browsers know what to do with the property. rest.js doesn't somehow make an older browser handle CORS. I'll add this before the next release |
Sure, but still it should be possible, imho.
Thanks! Appreciated. |
Trying to think through the best way to approach this. I think there are basically two options:
Option 1 is clearly specific to this need and only relevant to the XHR client. Option 2 has a chance of being applicable in other environments, and supporting other properties. Thoughts @webpro ? |
Definitely the 2nd option (there's plenty of attributes that can be set on the XHR(2) object). For what it's worth, that's also how jQuery does it. |
There are flags on the XHR that are important to set correctly in certain contexts. The 'withCredentials' property used by CORS is one example. As the context is essential, there is no good default value, thus we need to make it open to configuration. Rather than explicitly support each property, the xhr client now supports `request.mixin` which will copy all its properties directly on to the raw XHR object. Issue: #40
There are flags on the XHR that are important to set correctly in certain contexts. The 'withCredentials' property used by CORS is one example. As the context is essential, there is no good default value, thus we need to make it open to configuration. Rather than explicitly support each property, the xhr client now supports `request.mixin` which will copy all its properties directly on to the raw XHR object. Issue: #40
@webpro I have a fix on the dev branch if you wouldn't mind giving it a spin. One curious bit is that adding any new property to the XHR object in IE 6 causes the assignment to throw. So I added a check that the property exists on the XHR object before doing the assignment. |
haha, yah. in IE6, the xhr object is a "native" object, not a JavaScript object. |
Fix is on the dev branch and will be part of the next release. Please reopen if this doesn't fit your needs. |
Thanks a bunch, @scothis! Just tested with the dev branch and works great for me. |
How should I do an XHR/XDR that has
withCredentials
set totrue
? Basically I need it to send cookies along with the request (cookies were set server-side).In plain JS I can do:
Here's what I tried with rest.js:
However, the
request
object here is not the "raw"XMLHTTPRequest
, nor is the property copied onto the actual XHR object.Can you help me out here? :-)
The text was updated successfully, but these errors were encountered: