[ 9 posts ]

jed stark

  • Username: jstark
  • Joined: Fri Jul 09, 2010 5:57 am
  • Posts: 10
  • Offline
  • Profile

YUI 3.2.0 Y.IO versus YUI 3.1.2 with xhr

Post Posted: Wed Nov 03, 2010 1:41 pm
+0-
Hi everyone,
I recently tried updating from YUI 3.1.2 to 3.2.0, and now my xhr requests in Chrome dev, and Safari 5.0.2 give me this error:
XMLHttpRequest cannot load myurl. Origin mydomain is not allowed by Access-Control-Allow-Origin.

What happens is the first xhr request goes through fine, but subsequent requests no longer have the Origin header, even though I'm including my xhr config in the config object.

This was (and does) work with YUI 3.1.2, and I haven't changed any of my code, so I'm wondering what changed in Y.IO between the two. I read through the change notes and looked at the ticket list for IO and didn't see what could be causing it. Has anyone else ran into an XHR request issue with YUI 3.2.0?

Note - Firefox 3.6 works fine, and IE 8 works fine (we use the .swf for IE).

Thanks,
Jed

Thomas S. Sha

YUI Contributor

  • Username: tsha
  • Joined: Thu Jan 08, 2009 10:16 am
  • Posts: 206
  • Offline
  • Profile
Tags:

Re: YUI 3.2.0 Y.IO versus YUI 3.1.2 with xhr

Post Posted: Wed Nov 03, 2010 2:24 pm
+0-
I cannot think of any changes that would produce the described outcome. Any chance I could have a look at a functional example?

Regards,
Thomas

jed stark

  • Username: jstark
  • Joined: Fri Jul 09, 2010 5:57 am
  • Posts: 10
  • Offline
  • Profile

Re: YUI 3.2.0 Y.IO versus YUI 3.1.2 with xhr

Post Posted: Thu Nov 04, 2010 5:22 am
+0-
I don't have one publicly available, but I'll write one up and post as soon as I can.

Thank you,
Jed

jed stark

  • Username: jstark
  • Joined: Fri Jul 09, 2010 5:57 am
  • Posts: 10
  • Offline
  • Profile

Re: YUI 3.2.0 Y.IO versus YUI 3.1.2 with xhr

Post Posted: Thu Nov 04, 2010 6:19 am
+0-
Some more info:
If I switch to using the .swf object it works fine. It's only when I use:

if ('withCredentials' in xhr)
{
xdrConfig = { use: 'native', credentials: true };
}
else
{
//flash stuff
}

that Chrome and Safari stop working.They fall into the first branch (along with FF).

jed stark

  • Username: jstark
  • Joined: Fri Jul 09, 2010 5:57 am
  • Posts: 10
  • Offline
  • Profile
Tags:

Re: YUI 3.2.0 Y.IO versus YUI 3.1.2 with xhr

Post Posted: Thu Nov 04, 2010 7:46 am
+0-
It looks like there was a change in the _setHeaders() method in io-base.js that may be the culprit. We're going to debug through it to verify if it is or not. I'll post an update with what we find.

Thanks,
Jed

Thomas S. Sha

YUI Contributor

  • Username: tsha
  • Joined: Thu Jan 08, 2009 10:16 am
  • Posts: 206
  • Offline
  • Profile

Re: YUI 3.2.0 Y.IO versus YUI 3.1.2 with xhr

Post Posted: Thu Nov 04, 2010 11:15 am
+0-
You may be looking at the resolution of this ticket: http://yuilibrary.com/projects/yui3/ticket/2528893

Regards,
Thomas

jed stark

  • Username: jstark
  • Joined: Fri Jul 09, 2010 5:57 am
  • Posts: 10
  • Offline
  • Profile

Re: YUI 3.2.0 Y.IO versus YUI 3.1.2 with xhr

Post Posted: Thu Nov 04, 2010 12:46 pm
+0-
I did see that ticket, which made me think it was something there. We did track it down to the following line being removed in 3.2.0:
io-base.js
method: _create(c, i)
Code:
            // Remove the custom header when making cross-domain
            // requests to avoid unintended pre-flight requests
            // or access control conflicts.
            delete _headers['X-Requested-With'];



If you add this back in, then you can make cross-domain requests with Webkit. I'm not sure why that line was removed, and if something was supposed to be added somewhere else that got missed. Is there something we need to do differently for Webkit now compared to Mozilla?

Thanks,
Jed

Thomas S. Sha

YUI Contributor

  • Username: tsha
  • Joined: Thu Jan 08, 2009 10:16 am
  • Posts: 206
  • Offline
  • Profile
Tags:

Re: YUI 3.2.0 Y.IO versus YUI 3.1.2 with xhr

Post Posted: Thu Nov 04, 2010 2:18 pm
+1-
I see. After that was implemented (removing the "X-Requested-With" header from XDR requests), I received multiple requests to have it reinstated, simply because people had expected the default header to be issued.

The ability to suppress a default header, but not delete it, was recently pushed to development master (please see: http://yuilibrary.com/projects/yui3/ticket/2529324). I believe this will address the current issue. Or, you can just delete the custom header if it is of no consequence to your application.

Please let me know if that resolves the issue for you. Apologies for the inconvenience.

Regards,
Thomas

jed stark

  • Username: jstark
  • Joined: Fri Jul 09, 2010 5:57 am
  • Posts: 10
  • Offline
  • Profile
Tags:

Re: YUI 3.2.0 Y.IO versus YUI 3.1.2 with xhr

Post Posted: Fri Nov 05, 2010 10:09 am
+0-
Hi Thomas,

We used the ability to remove the header and now everything seems to be working fine, so thank you!

Also, there is a bug on chrome's list pertaining to this, since it's really a bug on there end:

http://code.google.com/p/chromium/issues/detail?id=55830#c1

Thanks for the timely replies and help,

Jed
  [ 9 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum