-
Notifications
You must be signed in to change notification settings - Fork 845
Added passing cookies from long polling session to web scoket #1058
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 passing cookies from long polling session to web scoket #1058
Conversation
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.
Overall looks fine. Do you think this should only be done when some config is set? I'm not sure if there's any chance some polling header would interfere with the WS side of things.
func addHeaders(to req: inout URLRequest, includingCookies additionalCookies: [HTTPCookie]? = nil) { | ||
|
||
var cookiesToAdd = [HTTPCookie]() | ||
cookiesToAdd += 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.
You can condense this line and the one above, right?
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.
yes, made this too
if let cookies = cookies { | ||
req.allHTTPHeaderFields = HTTPCookie.requestHeaderFields(with: cookies) | ||
func addHeaders(to req: inout URLRequest, includingCookies additionalCookies: [HTTPCookie]? = nil) { | ||
|
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.
nit: nix the space
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.
done
I looked where |
This commit introduces a major flaw: ALL cookies for ALL domains used in the app are sent to the socket-io-Server. So if the app uses a WebView, even those cookies set in the WebView will be sent to the socket.io server. @nuclearace @OneSman7 |
My intention was to pass cookies to support load balancers, not to change the way long polling sessions are created. |
@OneSman7 Multiple points:
|
|
@OneSman7 okay I see, you are right. But #1080 isn't a full fix because it can happen that you interact with a server in multiple ways, for example: via websocket and REST-API. In this scenario it wouldn't be a surprise if you don't want to share the cookies between the REST-API calls and the websocket. But with the current implementation there is just no way to achieve this. So in my opinion we should support 2 cases:
This could be achieved if we create a new field for SocketManager.config, for a HTTPCookieStorage, so the developer can set whatever he wants either a custom one or the "default"-shared one. If it's not set, the SocketEngine should create a custom one.
|
Ok. I see you seek not to prevent passing cookies from polling to web socket connection, but to prevent polling from using shared cookie storage altogether. I see no problem in that since load balancers support needs only to pass cookies from the current polling session storage, it does not matter if it is shared or not. |
@OneSman7 ok i testet this now but unfortunately I can't set a new HTTPCookieStorage because session!.configuration is not mutable and I didn't find a way to set it another way. Another approach would be that we use the |
No description provided.