JDK-8286052 : Proxy-authorization header not sent anymore with WebView
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: openjfx17
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2022-05-03
  • Updated: 2022-05-31
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
Since the introduction of HTTP2 in JDK-8211308, it seems that the proxy-authorization header is not sent anymore with the WebView.

Step to reproduce:
1) Start a proxy (I use Fiddler on my side)
2) Activate basic proxy authentication for example (on Fiddler under "Rules" -> "Require proxy authentication")
3) Run this sample :

"
import java.io.IOException;
import java.net.Authenticator;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.SocketAddress;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class ProxyAuthenticationWebView extends Application {
    static {
        // Allow basic authentication to work
        System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
        System.setProperty("jdk.http.auth.proxying.disabledSchemes", "");
        // ACTIVATE THIS LINE TO MAKE IT WORK
        //System.setProperty("com.sun.webkit.useHTTP2Loader", "false");
    }

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) {
        // Set the default user and password here
        Authenticator.setDefault(new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("1", "1".toCharArray());
            }
        });

        // Use the Fiddler proxy
        Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 8888));
        List<Proxy> proxyList = new ArrayList<>();
        proxyList.add(proxy);
        
        ProxySelector.setDefault(new ProxySelector() {
            @Override
            public List<Proxy> select(URI uri) {
                return proxyList;
            }

            @Override
            public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
                throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
            }
        });

        stage.setWidth(1280);
        stage.setHeight(720);

        WebView webView = new WebView();

        webView.getEngine().load("http://google.com");
        VBox vbox = new VBox(webView);

        Scene scene = new Scene(vbox);

        stage.setScene(scene);
        stage.show();
    }
}
"

Actual Results:
When you launch the program, you will see that no header "Proxy-authorization" is sent. Therefore, the page cannot be reached.

Expected results:
It you un-comment the line "System.setProperty("com.sun.webkit.useHTTP2Loader", "false");"
You will see that the Proxy-authorization header is well sent.
Comments
In the example code , Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 8888)); I have changed it to my own proxy url with port 80 and it is working (mac 64)
31-05-2022

Hello Jay, I've tested right now using JDK 18.0.1.1 from (https://jdk.java.net/18/) and targeting OpenJFX 19-ea+7: My dependencies are : <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-controls</artifactId> <version>19-ea+7</version> </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-web</artifactId> <version>19-ea+7</version> </dependency> I'm running on Windows 10. Fiddler is configured on port 8888 with password on "1" and "1" (but should be the default). So I find it odd that you don't reproduce. Something must be different
31-05-2022

The issue is not reproducible on latest openjfx, even If I comment/un-comment the line "System.setProperty("com.sun.webkit.useHTTP2Loader", "false");" So, can please provide the exact version of openjfx17 on which issue is reproducible?
31-05-2022