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

Y.io() XDR requests make preflight OPTIONS request #647

Open
lsmith opened this issue Apr 23, 2013 · 2 comments
Open

Y.io() XDR requests make preflight OPTIONS request #647

lsmith opened this issue Apr 23, 2013 · 2 comments
Labels

Comments

@lsmith
Copy link
Contributor

lsmith commented Apr 23, 2013

Posted for @chrisrhut, migrated from http://yuilibrary.com/projects/yui3/ticket/2533248

XDR requests on Chrome suddenly started making additional "preflight" OPTIONS requests in YUI 3.9.1. This line is the culprit:

// Convert falsy values to an empty string. This way IE can't be
// rediculous and translate `undefined` to "undefined".
data || (data = );

when the call is made to 'transaction.c.send(data);', Chrome adds the Content-Length: 0 header which, since it's not one of the "Simple" headers defined by the W3C (http://www.w3.org/TR/cors/#simple-header) triggers a preflight OPTIONS request to ensure CORS is authorized.
One possible fix is to make the above change conditional, as in:

if (!SUPPORTS_CORS) {
    // Convert falsy values to an empty string. This way IE can't be
    // ridiculous and translate `undefined` to "undefined".
    data || (data = );
}

The above is confirmed to work with Chrome and Firefox, have not tested IE.

@lsmith
Copy link
Contributor Author

lsmith commented Apr 23, 2013

This is a regression that occurred somewhere between 3.7.1 and 3.9.1.

@lsmith
Copy link
Contributor Author

lsmith commented Apr 23, 2013

Per my trak comment, I would recommend forking on data and calling send() without an argument rather than dance about with "acceptable" values between implementations.

Mind you, this should also be validated against the IE content-length issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant