These are chat archives for canjs/canjs

10th
Oct 2017
Morgan Heimbeck
@Xitstrategies
Oct 10 2017 15:51
Hey, if someone could look at canjs/can-ajax#13 that would be great!
Morgan Heimbeck
@Xitstrategies
Oct 10 2017 15:57
Also, I am having issues with the isSimpleCors including the POST method, because I want it to be a json content, but because POST is a simple CORS type, can-ajax is using can-param to parse the data, but can-param is not parsing all data, dates in particular. Has anyone else run in to this? I have a fork of can-ajax and removed POST from the isSimpleCors check and it is working the way I want it. simple cors does not require a preflight check but that doesn't mean you have to avoid it with post. Thoughts?
Brad Momberger
@bmomberger-bitovi
Oct 10 2017 16:10
@Xitstrategies can-ajax can't have can-util as a dependency
That's a cyclic dep because can-util is already depending on can-ajax
But you did help find a bug in my cycle detection script, so thanks for that!
Brad Momberger
@bmomberger-bitovi
Oct 10 2017 16:17
My recommendation is to import can-reflect and use canReflect.assignDeep() instead. I'll put that in a review on the PR
Chasen Le Hara
@chasenlehara
Oct 10 2017 17:11
@Xitstrategies It’s been a while since I’ve worked with CORS stuff, but I think I am following along with what you’re saying.
It seems like the logic in that section of the code might be wrong, but I’m not 100% sure how.
Should isSimpleCors be false if isJsonContentType is true?
Morgan Heimbeck
@Xitstrategies
Oct 10 2017 18:18
@bmomberger-bitovi Thanks for the message, I will get on that.
Morgan Heimbeck
@Xitstrategies
Oct 10 2017 18:24
@chasenlehara I was thinking that the isSimpleCors assignment needs to be moved up to determine if the content Type was explicitly set to json, which is not a supported contentType for simpleCors. But by moving up there, then the logic from L186-L193 can stay the same and can be turned in to a simpleCors without needing preflight. Because isJsonContentType is defaulted up on L117.
Chasen Le Hara
@chasenlehara
Oct 10 2017 19:49
Ok, so isSimpleCors should also check for isJsonContentType, something like var isSimpleCors = o.crossDomain && ! isJsonContentType && ['GET', 'POST', 'HEAD'].indexOf(type) !== -1;
Morgan Heimbeck
@Xitstrategies
Oct 10 2017 20:10
@bmomberger-bitovi alright, took some mistakes to get the right thing, but should be good to go now.
Morgan Heimbeck
@Xitstrategies
Oct 10 2017 20:48
@chasenlehara yes