@Test public void testExecuteHttpGet() throws Exception { DummyServer server = new DummyServer( 1337 ); URL url = new URL( "http", "localhost", 1337, "/" ); Properties p = new Properties(); p.setProperty( Configuration.URL, url.toExternalForm() ); DownloadConfiguration conf = DownloadConfiguration.create( p ); ResponseHandler<String> responseHandler = ResponseHandler.fromFunction( input -> input.getContentAsString() ); server.start(); String response = JettyClient.getDataAndExecuteResponseHandler( url, conf, responseHandler ); server.stop(); assertEquals( 1, server.timesHandlerCalled() ); assertEquals( "OK\r\n", response ); }
public static <T> T getDataAndExecuteResponseHandler( final URL url, final DownloadConfiguration conf, final ResponseHandler<T> handler ) throws IOException { logger.debug( "url: {}", url ); final Request request = createHttpGet( url, conf ); try { ContentResponse response = request.send(); return handler.apply( response ); } catch ( InterruptedException | TimeoutException | ExecutionException ex ) { throw new IOException( ex ); } }
JettyClient { public static <T> T getDataAndExecuteResponseHandler( final URL url, final DownloadConfiguration conf, final ResponseHandler<T> handler ) throws IOException { logger.debug( "url: {}", url ); final Request request = createHttpGet( url, conf ); try { ContentResponse response = request.send(); return handler.apply( response ); } catch ( InterruptedException | TimeoutException | ExecutionException ex ) { throw new IOException( ex ); } } }
JettyClient { public static <T> T getDataAndExecuteResponseHandler( final URL url, final DownloadConfiguration conf, final ResponseHandler<T> handler ) throws IOException { logger.debug( "url: {}", url ); final Request request = createHttpGet( url, conf ); try { ContentResponse response = request.send(); return handler.apply( response ); } catch ( InterruptedException | TimeoutException | ExecutionException ex ) { throw new IOException( ex ); } }  }
JettyClient { public static <T> T getDataAndExecuteResponseHandler( final URL url, final DownloadConfiguration conf, final ResponseHandler<T> handler ) throws IOException { logger.debug( "url: {}", url ); final Request request = createHttpGet( url, conf ); try { ContentResponse response = request.send(); return handler.apply( response ); } catch ( InterruptedException | TimeoutException | ExecutionException ex ) { throw new IOException( ex ); } }  static void startHttpClient(); static void stopHttpClient(); static Request createHttpGet( final URL url, final DownloadConfiguration conf ); static T getDataAndExecuteResponseHandler( final URL url, final DownloadConfiguration conf,
        final ResponseHandler<T> handler ); static Document getDocument( final URL url, final DownloadConfiguration conf ); }
JettyClient { public static <T> T getDataAndExecuteResponseHandler( final URL url, final DownloadConfiguration conf, final ResponseHandler<T> handler ) throws IOException { logger.debug( "url: {}", url ); final Request request = createHttpGet( url, conf ); try { ContentResponse response = request.send(); return handler.apply( response ); } catch ( InterruptedException | TimeoutException | ExecutionException ex ) { throw new IOException( ex ); } }  static void startHttpClient(); static void stopHttpClient(); static Request createHttpGet( final URL url, final DownloadConfiguration conf ); static T getDataAndExecuteResponseHandler( final URL url, final DownloadConfiguration conf,
        final ResponseHandler<T> handler ); static Document getDocument( final URL url, final DownloadConfiguration conf );  }