1 Reply Latest reply on Jul 16, 2013 11:49 AM by Peterz-Oracle

    JavaFX WebView custom protocol handler

    e9a73435-d60e-4dd6-98ac-5b2bf5eb9283

      Hello all

       

      I am trying to create my custom URLConnection in order to read some response binary data from requests that WebView makes to a page. What I have done so far is listed below but I am missing some important bits. All I want to achieve from this is read the binary data of a response of a certain request to the server. Any help, links or clues or piece of code would be much appreciated. Thanks

       

      My Custom URLStreamHandlerFactory

      public class MYURLStreamHandlerFactory implements URLStreamHandlerFactory{

           public URLStreamHandler createURLStreamHandler(String protocol){

                return new MyURLStreamHandler();

           }

      }

      My custom URLStreamHandler

      public class MyURLStreamHandler extends java.net.URLStreamHandler{

           protected URLConnection openConnection(URL u){

                return new MyURLConnection(u);

           }

      }

      Finally my custom URLConnection

      public class MyURLConnection extends URLConnection { 

           public MyURLConnection(URL url) {

           super(url);

           } 

       

          public OutputStream getOutputStream() {

                return getOutputStream();

            } 

           public InputStream getInputStream() {

                return new InputStream() {


                     @Override

                     public int read() throws IOException {          

                          System.out.println("THIs: " + this.read());

                         throw new UnsupportedOperationException("Not supported yet."); 

                     }    

                 };

            }

       

            public void connect() throws IOException {

                 throw new UnsupportedOperationException("Not supported yet.");

            }

      }