Bug 209465 - [Curl] Proxy setting API does not work until Network process starts.
Summary: [Curl] Proxy setting API does not work until Network process starts.
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Takashi Komori
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-24 01:31 PDT by Takashi Komori
Modified: 2020-08-11 13:49 PDT (History)
19 users (show)

See Also:


Attachments
Patch (23.78 KB, patch)
2020-03-24 02:28 PDT, Takashi Komori
no flags Details | Formatted Diff | Diff
Patch (23.01 KB, patch)
2020-04-01 20:00 PDT, Takashi Komori
no flags Details | Formatted Diff | Diff
Patch (49.90 KB, patch)
2020-04-28 02:14 PDT, Takashi Komori
Hironori.Fujii: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Takashi Komori 2020-03-24 01:31:59 PDT
On Curl port we set proxy server by calling WKWebsiteDataStoreEnableCustomNetworkProxySettings.
But the API is not working before start of the Network process.
This is because the API can't send proxy setting message to the process which doesn't start yet.

In this ticket we will fix the flaw by passing proxy setting with initialization parameters to the Network process.
Comment 1 Takashi Komori 2020-03-24 02:28:51 PDT
Created attachment 394356 [details]
Patch
Comment 2 Takashi Komori 2020-03-24 02:29:43 PDT
Curl.EnableProxyBeforeLoading test checks the situation WKWebsiteDataStoreEnableCustomNetworkProxySettings is invoked before start of Network Process.
Comment 3 Basuke Suzuki 2020-03-30 21:54:26 PDT
Comment on attachment 394356 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394356&action=review

This is an informal review.

> Tools/TestWebKitAPI/Tests/WebKit/curl/Proxy.cpp:98
> +    auto [proxyServer, proxyURL] = createServer("", 59001, "Respond from proxy server");

I cannot follow the logic. It seems this is the test for proxy server setting and these two `createServer` denote real http and proxy server for test environment, right? Where the logic to implement proxying?
Comment 4 Takashi Komori 2020-03-31 07:12:00 PDT
(In reply to Basuke Suzuki from comment #3)
> Comment on attachment 394356 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=394356&action=review
> 
> This is an informal review.
> 
> > Tools/TestWebKitAPI/Tests/WebKit/curl/Proxy.cpp:98
> > +    auto [proxyServer, proxyURL] = createServer("", 59001, "Respond from proxy server");
> 
> I cannot follow the logic. It seems this is the test for proxy server
> setting and these two `createServer` denote real http and proxy server for
> test environment, right? Where the logic to implement proxying?

When a browser connects via proxy it send a request line to the proxy as almost same as direct connection, and gets response from the proxy.
Whether using proxy or not, request and response sequence is almost same (The request line differs).
So just checking responses we can't distinct whether the responses come directly or via proxy.

In this test we use the behavior that a browser always connects to the proxy server when proxy is set.
If proxy setting works, the browser connects to specified proxy server otherwise it connects to specified URL directly.
We can check the response is from proxy or not by only checking response.

In EnableProxyBeforeLoading test, if proxy server is set to http://127.0.0.1:59001 WKPageLoadURL always connects to it.
Comment 5 Basuke Suzuki 2020-03-31 09:54:43 PDT
(In reply to Takashi Komori from comment #4)
> When a browser connects via proxy it send a request line to the proxy as
> almost same as direct connection, and gets response from the proxy.
> Whether using proxy or not, request and response sequence is almost same
> (The request line differs).
> So just checking responses we can't distinct whether the responses come
> directly or via proxy.
> 
> In this test we use the behavior that a browser always connects to the proxy
> server when proxy is set.
> If proxy setting works, the browser connects to specified proxy server
> otherwise it connects to specified URL directly.
> We can check the response is from proxy or not by only checking response.
> 
> In EnableProxyBeforeLoading test, if proxy server is set to
> http://127.0.0.1:59001 WKPageLoadURL always connects to it.

Make sense. Looks good to me.
Comment 6 Fujii Hironori 2020-03-31 13:50:38 PDT
Comment on attachment 394356 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394356&action=review

> Source/JavaScriptCore/ChangeLog:3
> +        [Curl] Proxy setting API does not working until Network process starts.

working → work
Remove the period. Let's follow the majority style.
This sentence doesn't make send to me. Do you mean "Proxy setting API does not work if Network process isn't started"?

> Tools/TestWebKitAPI/Tests/WebKit/curl/HTTPServer.cpp:40
> +    auto& endpoint = Inspector::RemoteInspectorSocketEndpoint::singleton();

I don't think it's a good idea to use Inspector::RemoteInspectorSocketEndpoint here.
Why don't you use Tools/TestWebKitAPI/TCPServer.cpp?

> Tools/TestWebKitAPI/Tests/WebKit/curl/HTTPServer.h:69
> +class HTTPServer final : public RemoteInspectorSocketEndpoint::Listener {

Do you know there is already TestWebKitAPI::HTTPServer class in Tools/TestWebKitAPI/cocoa/HTTPServer.mm?
Comment 7 Fujii Hironori 2020-03-31 14:03:24 PDT
Comment on attachment 394356 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394356&action=review

> Tools/TestWebKitAPI/Tests/WebKit/curl/HTTPServer.cpp:35
> +HTTPServer::HTTPServer(String&& address, uint16_t port, HTTPRequestHandler::RequestHandler&& requestHandler)

String&& address → const String& address or const char*.
Comment 8 Fujii Hironori 2020-03-31 14:18:36 PDT
Comment on attachment 394356 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394356&action=review

> Tools/TestWebKitAPI/Tests/WebKit/curl/Proxy.cpp:84
> +    auto url = makeString("http://127.0.0.1:", String::number(server->getPort().value()));

If you statically specify "127.0.0.1" here, createServer doesn't need to take 'address' as the argument.

> Tools/TestWebKitAPI/Tests/WebKit/curl/Proxy.cpp:133
> +    auto [proxyServer, proxyURL] = createServer("", 59001, "Respond from proxy server");

You can specify '0' to use unused port.
Comment 9 Fujii Hironori 2020-03-31 14:24:44 PDT
Comment on attachment 394356 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394356&action=review

> Tools/TestWebKitAPI/Tests/WebKit/curl/Proxy.cpp:132
> +    auto [httpServer, httpURL] = createServer("", 59000, "Respond from HTTP server");

The word "respond" is a verb. I think "Response from HTTP server" or  "Responded from HTTP server" are better than "Respond from HTTP server".
Comment 10 Fujii Hironori 2020-03-31 14:25:46 PDT
Comment on attachment 394356 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394356&action=review

>> Tools/TestWebKitAPI/Tests/WebKit/curl/Proxy.cpp:132
>> +    auto [httpServer, httpURL] = createServer("", 59000, "Respond from HTTP server");
> 
> The word "respond" is a verb. I think "Response from HTTP server" or  "Responded from HTTP server" are better than "Respond from HTTP server".

"Response from HTTP server" or  "HTTP server responded"
Comment 11 Takashi Komori 2020-04-01 20:00:57 PDT
Created attachment 395239 [details]
Patch
Comment 12 Takashi Komori 2020-04-01 20:26:43 PDT
(In reply to Fujii Hironori from comment #6)
> Comment on attachment 394356 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=394356&action=review
> 
> > Source/JavaScriptCore/ChangeLog:3
> > +        [Curl] Proxy setting API does not working until Network process starts.
> 
> working → work
> Remove the period. Let's follow the majority style.
> This sentence doesn't make send to me. Do you mean "Proxy setting API does
> not work if Network process isn't started"?

Fixed.

> 
> > Tools/TestWebKitAPI/Tests/WebKit/curl/HTTPServer.cpp:40
> > +    auto& endpoint = Inspector::RemoteInspectorSocketEndpoint::singleton();
> 
> I don't think it's a good idea to use
> Inspector::RemoteInspectorSocketEndpoint here.
> Why don't you use Tools/TestWebKitAPI/TCPServer.cpp?
> 
> > Tools/TestWebKitAPI/Tests/WebKit/curl/HTTPServer.h:69
> > +class HTTPServer final : public RemoteInspectorSocketEndpoint::Listener {
> 
> Do you know there is already TestWebKitAPI::HTTPServer class in
> Tools/TestWebKitAPI/cocoa/HTTPServer.mm?

We chose RemoteInspectorSocketEndpoint because it is working on wincairo.
If we use TCPServer, we have to implement some for wincairo.
RemoteInspectorSocketEndpoint is not generic name, but its implementation seems to be for generic server connection.
Comment 13 Takashi Komori 2020-04-01 20:29:12 PDT
(In reply to Fujii Hironori from comment #7)
> Comment on attachment 394356 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=394356&action=review
> 
> > Tools/TestWebKitAPI/Tests/WebKit/curl/HTTPServer.cpp:35
> > +HTTPServer::HTTPServer(String&& address, uint16_t port, HTTPRequestHandler::RequestHandler&& requestHandler)
> 
> String&& address → const String& address or const char*.

Changed to const char*
Comment 14 Takashi Komori 2020-04-01 20:29:52 PDT
(In reply to Fujii Hironori from comment #8)
> Comment on attachment 394356 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=394356&action=review
> 
> > Tools/TestWebKitAPI/Tests/WebKit/curl/Proxy.cpp:84
> > +    auto url = makeString("http://127.0.0.1:", String::number(server->getPort().value()));
> 
> If you statically specify "127.0.0.1" here, createServer doesn't need to
> take 'address' as the argument.
> 
> > Tools/TestWebKitAPI/Tests/WebKit/curl/Proxy.cpp:133
> > +    auto [proxyServer, proxyURL] = createServer("", 59001, "Respond from proxy server");
> 
> You can specify '0' to use unused port.

FIXED.
Comment 15 Takashi Komori 2020-04-01 20:30:50 PDT
(In reply to Fujii Hironori from comment #10)
> Comment on attachment 394356 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=394356&action=review
> 
> >> Tools/TestWebKitAPI/Tests/WebKit/curl/Proxy.cpp:132
> >> +    auto [httpServer, httpURL] = createServer("", 59000, "Respond from HTTP server");
> > 
> > The word "respond" is a verb. I think "Response from HTTP server" or  "Responded from HTTP server" are better than "Respond from HTTP server".
> 
> "Response from HTTP server" or  "HTTP server responded"

Changed to "Response from HTTP server"
Comment 16 Fujii Hironori 2020-04-01 20:43:11 PDT
Comment on attachment 395239 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=395239&action=review

> Source/JavaScriptCore/ChangeLog:3
> +        [Curl] Proxy setting API does not work until Network process starts.

Remove the period. Let's follow the majority style.
This sentence doesn't make send to me. Do you mean "Proxy setting API does not work if Network process isn't started"?
Comment 17 Fujii Hironori 2020-04-01 20:45:32 PDT
(In reply to Takashi Komori from comment #12)
> > 
> > > Tools/TestWebKitAPI/Tests/WebKit/curl/HTTPServer.cpp:40
> > > +    auto& endpoint = Inspector::RemoteInspectorSocketEndpoint::singleton();
> > 
> > I don't think it's a good idea to use
> > Inspector::RemoteInspectorSocketEndpoint here.
> > Why don't you use Tools/TestWebKitAPI/TCPServer.cpp?
> > 
> > > Tools/TestWebKitAPI/Tests/WebKit/curl/HTTPServer.h:69
> > > +class HTTPServer final : public RemoteInspectorSocketEndpoint::Listener {
> > 
> > Do you know there is already TestWebKitAPI::HTTPServer class in
> > Tools/TestWebKitAPI/cocoa/HTTPServer.mm?
> 
> We chose RemoteInspectorSocketEndpoint because it is working on wincairo.
> If we use TCPServer, we have to implement some for wincairo.
> RemoteInspectorSocketEndpoint is not generic name, but its implementation
> seems to be for generic server connection.

I think Apple folks ask you to use TCPServer. Could you ask them?
Comment 18 Takashi Komori 2020-04-01 21:05:31 PDT
(In reply to Fujii Hironori from comment #17)
> I think Apple folks ask you to use TCPServer. Could you ask them?

OK I try to use TCPServer on wincairo.
Comment 19 Fujii Hironori 2020-04-01 21:31:02 PDT
I'm also concerning the duplicated TestWebKitAPI::HTTPServer classes.
It'd also be great if you will port HTTPServer.mm into C++, and improve it, and use it.
Comment 20 Takashi Komori 2020-04-28 02:14:54 PDT
Created attachment 397822 [details]
Patch
Comment 21 Takashi Komori 2020-04-28 02:17:22 PDT
We made a http server for tests.
The source has Win suffix but the interfaces resemble cocoa's HTTPServer and we will be able to use this code on other ports commonly.

We added Win suffix because we think it is hard to replace cocoa's HTTPServer at once.
But we have a plan to replace it.
Comment 22 Fujii Hironori 2020-08-11 13:49:04 PDT
Comment on attachment 397822 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=397822&action=review

> Tools/ChangeLog:47
> +        * TestWebKitAPI/win/HTTPServerWin.cpp: Added.

Bug 215379 is going to land HTTPServer.cpp as a separate patch. Let's redo this patch after Bug 215379.