@Test public void unauthenticated() throws Exception { stubFor(get(urlEqualTo("/foo")).willReturn(aResponse().withStatus(HttpStatus.SC_OK).withBody("bar"))); try (HttpHandler handler = new HttpHandler(url, options)) { handler.get("foo"); } verify(getRequestedFor(urlEqualTo("/foo")).withoutHeader("Authorization")); }
public HttpResponse get(String path) throws IOException { HttpGet get = new HttpGet(url.resolve(path)); creds.ifPresent(x -> get.setHeader("Authorization", "Basic " + x)); return client.execute(get); }
HttpHandler implements AutoCloseable { public HttpResponse get(String path) throws IOException { HttpGet get = new HttpGet(url.resolve(path)); creds.ifPresent(x -> get.setHeader("Authorization", "Basic " + x)); return client.execute(get); } }
HttpHandler implements AutoCloseable { public HttpResponse get(String path) throws IOException { HttpGet get = new HttpGet(url.resolve(path)); creds.ifPresent(x -> get.setHeader("Authorization", "Basic " + x)); return client.execute(get); } HttpHandler(URI url, OnrampOptions options); }
HttpHandler implements AutoCloseable { public HttpResponse get(String path) throws IOException { HttpGet get = new HttpGet(url.resolve(path)); creds.ifPresent(x -> get.setHeader("Authorization", "Basic " + x)); return client.execute(get); } HttpHandler(URI url, OnrampOptions options); HttpResponse get(String path); HttpResponse post(String path, HttpEntity entity); @Override void close(); static HttpHandler paver(OnrampOptions options); static HttpHandler onramp(OnrampOptions options); }
HttpHandler implements AutoCloseable { public HttpResponse get(String path) throws IOException { HttpGet get = new HttpGet(url.resolve(path)); creds.ifPresent(x -> get.setHeader("Authorization", "Basic " + x)); return client.execute(get); } HttpHandler(URI url, OnrampOptions options); HttpResponse get(String path); HttpResponse post(String path, HttpEntity entity); @Override void close(); static HttpHandler paver(OnrampOptions options); static HttpHandler onramp(OnrampOptions options);  }