WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 215456
Set Sec-WebSocket-Protocol for WebSocket NSURLSession code path
https://bugs.webkit.org/show_bug.cgi?id=215456
Summary
Set Sec-WebSocket-Protocol for WebSocket NSURLSession code path
youenn fablet
Reported
2020-08-13 09:30:50 PDT
Set Sec-WebSocket-Protocol for WebSocket NSURLSession code path
Attachments
Patch
(2.52 KB, patch)
2020-08-14 10:10 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(2.59 KB, patch)
2020-08-14 10:49 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2020-08-13 09:31:43 PDT
<
rdar://problem/66996369
>
youenn fablet
Comment 2
2020-08-14 10:10:13 PDT
Created
attachment 406601
[details]
Patch
Alex Christensen
Comment 3
2020-08-14 10:12:06 PDT
Comment on
attachment 406601
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=406601&action=review
> Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm:1571 > + [requestWithProtocols addValue: StringView(protocol).createNSStringWithoutCopying().get() forHTTPHeaderField:@"Sec-WebSocket-Protocol"];
This seems unsafe. Why not just make a copy?
Alex Christensen
Comment 4
2020-08-14 10:25:22 PDT
Comment on
attachment 406601
[details]
Patch This seems like a good workaround for the fact that there is webSocketTaskWithURL:protocols: but no webSocketTaskWithRequest:protocols:. Let's introduce that API and do this on operating system versions that don't have it.
youenn fablet
Comment 5
2020-08-14 10:33:35 PDT
(In reply to Alex Christensen from
comment #4
)
> Comment on
attachment 406601
[details]
> Patch > > This seems like a good workaround for the fact that there is > webSocketTaskWithURL:protocols: but no webSocketTaskWithRequest:protocols:. > Let's introduce that API and do this on operating system versions that don't > have it.
Actually there is, let's use that.
Alex Christensen
Comment 6
2020-08-14 10:34:18 PDT
There isn't on Catalina.
youenn fablet
Comment 7
2020-08-14 10:35:39 PDT
(In reply to Alex Christensen from
comment #6
)
> There isn't on Catalina.
We might actually want to bump HAVE_NSURLSESSION_WEBSOCKET to Big Sur.
youenn fablet
Comment 8
2020-08-14 10:43:14 PDT
(In reply to Alex Christensen from
comment #6
)
> There isn't on Catalina.
I looked too quickly, there is no such thing given we also want to set other headers like User-Agent.
youenn fablet
Comment 9
2020-08-14 10:49:07 PDT
Created
attachment 406606
[details]
Patch
jmehta
Comment 10
2020-08-14 10:52:52 PDT
There is no variant of WebSocket task with request and protocols. The only variant with protocols is the one that takes a url. The client can add the protocol headers manually on the request which would achieve the same result. I think in WebKit's case we want to pass along the request since other information about main document etc will also be needed to lookup cookies etc, so moving to the url variant might not work.
youenn fablet
Comment 11
2020-08-14 10:54:38 PDT
> I think in WebKit's case we want to pass along the request since other > information about main document etc will also be needed to lookup cookies > etc, so moving to the url variant might not work.
Right, I do not think offering webSocketTaskWithRequest:protocols: provides much really. If you are using webSocketTaskWithRequest, you are already out of WebSocket standard API.
jmehta
Comment 12
2020-08-14 10:56:59 PDT
(In reply to youenn fablet from
comment #11
)
> > I think in WebKit's case we want to pass along the request since other > > information about main document etc will also be needed to lookup cookies > > etc, so moving to the url variant might not work. > > Right, I do not think offering webSocketTaskWithRequest:protocols: provides > much really. > If you are using webSocketTaskWithRequest, you are already out of WebSocket > standard API.
Yup!
Alex Christensen
Comment 13
2020-08-14 11:06:19 PDT
Comment on
attachment 406606
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=406606&action=review
> Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm:1569 > + auto *nsRequest = request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody);
I think this returns an NSMutableURLRequest, so we could avoid a copy. Probably not too important here.
> Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm:1571 > + NSMutableURLRequest *requestWithProtocols = [[nsRequest mutableCopy] autorelease];
adoptNS could avoid putting a reference in the autorelease pool.
Alex Christensen
Comment 14
2020-08-14 14:04:37 PDT
Comment on
attachment 406606
[details]
Patch ok
youenn fablet
Comment 15
2020-08-17 05:17:00 PDT
> > Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm:1569 > > + auto *nsRequest = request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody); > > I think this returns an NSMutableURLRequest, so we could avoid a copy. > Probably not too important here.
It does not seem so from ResourceRequest::nsURLRequest.
EWS
Comment 16
2020-08-17 05:21:20 PDT
Committed
r265752
: <
https://trac.webkit.org/changeset/265752
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 406606
[details]
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug