HttpClient { public void send(String method, String url, final List<String> requestBodyLines) { send(HttpRequestBuilder.<Integer>forUrl(url) .method(method) .body(requestBodyLines) .build()); }  void send(String method, String url, final List<String> requestBodyLines); T send(final String method, final String url, final Map<String, String> headerFields,
					  OutputStreamHandler outputStreamHandler, ResponseHandler<T> responseHandler); T send(final HttpRequest<T> request); static String getBasicAuthFromUserInfo(URL url); static String removeUserInfo(String url);  }
@Test public void testBasicAuth() throws Exception { final boolean[] handled = {false}; startWithHandler(new AbstractHandler() { @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { baseRequest.setHandled(true); assertEquals("Basic dXNlcjpwYXNz", request.getHeader("Authorization")); assertThat(request.getQueryString()).isEqualTo("bar=baz"); handled[0] = true; } }); assertEquals(Integer.valueOf(200), httpClient.send(HttpRequestBuilder.<Integer>forUrl("http: .successHandler(new StatusCodeResponseHandler()).build())); assertTrue(handled[0]); }
@Test public void testBasicAuthException() throws Exception { startWithHandler(new AbstractHandler() { @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { baseRequest.setHandled(true); response.sendError(HttpServletResponse.SC_UNAUTHORIZED); } }); final String url = "http: final String urlWithoutAuth = "http: httpClient.send(HttpRequestBuilder.<Integer>forUrl(url) .successHandler((httpRequest, is, statusCode, e) -> { fail(); return null; }) .errorHandler((httpRequest, is, statusCode, e) -> { assertThat(statusCode).isEqualTo(401); assertThat(e.getMessage()) .doesNotContain(url) .contains(urlWithoutAuth); return null; }) .build()); }