[TIMOB-7825] MobileWeb: Expose withCredentials and userAgent on HTTPClient
GitHub Issue | n/a |
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-03-19T22:44:49.000+0000 |
Affected Version/s | Release 2.0.0 |
Fix Version/s | Release 2.0.0, Sprint 2012-06 |
Components | MobileWeb |
Labels | n/a |
Reporter | Dawson Toth |
Assignee | Chris Barber |
Created | 2012-02-27T11:20:56.000+0000 |
Updated | 2017-03-04T00:17:31.000+0000 |
Description
Feature
Two properties are needed for a particular instance of cross domain requesting:
- Expose the withCredentials property of XMLHttpRequest via HTTPClient.
- Allow overriding or excluding the UserAgent request header via a userAgent property passed in the constructor.
Why
For some cross domain requests, these properties need to be set, or the request won't be valid. (Cookies and authorization need to be included, and the server doesn't accept the UserAgent header.)
Comments
JSON Source
PR sent: https://github.com/appcelerator/titanium_mobile/pull/1519
Do we need this? We've been testing with cross-domain XHR and it works as long as the server has properly configured CORS (cross-origin resource sharing). Furthermore, this should probably be implemented as a property, not a method. A "withCreditials" will automatically create the setter/getter method.
Is there any reason we can't always set setWithCredentials('true')?
What is the fallback for browsers that don't support XHR2 (i.e. support for setWithCredentials())?
PR updated per your comments. To the best of my knowledge, browsers that don't support XHR2 will ignore the property. We probably could set withCredentials to true all the time, but I think it would only be a problem if the server wasn't sending "Access-Control-Allow-Credentials: true".
Pull Request: https://github.com/appcelerator/titanium_mobile/pull/1749 Note: we removed support for Ti.userAgent entirely, and are no longer setting the "UserAgent" header internally.
Closing ticket due to MobileWeb no longer being supported.