-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
Added Cookie Header to XML and Websocket request #10575
Conversation
Why is this the right behavior? It's not clear to me that these libraries should automatically use cookies. FWIW #9114 is a similar pull request. |
Fetch & Websocket API should be a drop-in replacement for the web version of the code. |
I accepted #9114 for websockets since that had already been reviewed by a bunch of folks, so I think you will need to update this to just center on non websocket things. |
OK sounds good to me. |
Hey, so I am unclear on the status of this, maybe I wasn't specific enough. With #9114 does this PR need to be updated, or do you think it's ready to go right now? In particular I am curious how we should test given the two different PRs that the behavior is the same cross-platform. |
@lacker I reviewed the #9114, that PR fixes sending cookie header in websocket request for android websocket. This PR also does the same for IOS side. Since the test for #9114 was written in JS and platform agnostics, same test also works for this PR. |
Can you make this be tested automatically? It seems like that manual procedure in the other pull request, nobody is ever going to do that. |
Ping @clozr, see earlier feedback. |
To test automatically we will need a test mode callback to examine the headers being sent for websocket connect request. Give me couple of days to do it. |
Is this PR ready to be merged? @clozr |
I side up with everybody who's waiting for this feature. Are there any plans on when this PR is going to be merged? |
I believe we should merge this. |
@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification. |
@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
1 similar comment
@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@clozr Looks like we have weird difficulties with merging this PR. Could you please rebase it on master? |
22a2a5e
to
d3b3c35
Compare
Just updated the PR to facebook/master. Please let me know if you come across any problem |
@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@clozr It seems like this PR can't be merged. Could you take a look at the build failure? |
3b6849a
to
15a9471
Compare
Looks like there were some unrelated issues. I have rebased it again. Let's see how the current build goes. |
@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Looks Good now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am soooory for late detailed review but code style should be fixed.
@@ -63,6 +63,9 @@ - (NSURLSessionDataTask *)sendRequest:(NSURLRequest *)request | |||
callbackQueue.maxConcurrentOperationCount = 1; | |||
callbackQueue.underlyingQueue = [[_bridge networking] methodQueue]; | |||
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; | |||
[ configuration setHTTPShouldSetCookies:YES]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, fix codestyle across all changed lines. This diff cannot be merged without it (because of linter).
Libraries/Network/RCTNetworking.mm
Outdated
NSDictionary* headers = [RCTConvert NSDictionary:query[@"headers"]]; | ||
[headers enumerateKeysAndObjectsUsingBlock:^(NSString *key, id value, BOOL *stop) { | ||
//request.allHTTPHeaderFields = [self stripNullsInRequestHeaders:[RCTConvert NSDictionary:query[@"headers"]]]; | ||
if(value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add space.
Libraries/Network/RCTNetworking.mm
Outdated
// set supplied headers | ||
NSDictionary* headers = [RCTConvert NSDictionary:query[@"headers"]]; | ||
[headers enumerateKeysAndObjectsUsingBlock:^(NSString *key, id value, BOOL *stop) { | ||
//request.allHTTPHeaderFields = [self stripNullsInRequestHeaders:[RCTConvert NSDictionary:query[@"headers"]]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this line.
// fetch). To get secure cookies for wss URLs, replace wss with https | ||
// in the URL. | ||
NSURLComponents *components = [NSURLComponents componentsWithURL:URL resolvingAgainstBaseURL:true]; | ||
if ([[components.scheme lowercaseString] isEqualToString:@"wss"]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, use dot notation for lowercaseString
.
if ([[components.scheme lowercaseString] isEqualToString:@"wss"]) { | ||
components.scheme = @"https"; | ||
} | ||
// Load and set the cookie header. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add new line.
// Load and set the cookie header. | ||
NSArray<NSHTTPCookie *> *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:URL]; | ||
request.allHTTPHeaderFields = [NSHTTPCookie requestHeaderFieldsWithCookies:cookies]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this line.
Libraries/Network/RCTNetworking.mm
Outdated
request.allHTTPHeaderFields = [NSHTTPCookie requestHeaderFieldsWithCookies:cookies]; | ||
|
||
|
||
// set supplied headers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capital letter, full stop at the end.
Libraries/Network/RCTNetworking.mm
Outdated
|
||
|
||
// set supplied headers | ||
NSDictionary* headers = [RCTConvert NSDictionary:query[@"headers"]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NSDictionary *headers = ...
Fixed the lint errors. Let me know any more issues |
@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Continuation of Pull Request #7167
#7167
Needed to clean my repository. So created this Pull Request