use of org.glassfish.jersey.client.ClientConfig in project dropwizard by dropwizard.
the class JerseyClientBuilder method buildConfig.
private Configuration buildConfig(final String name, final ExecutorService threadPool, final ObjectMapper objectMapper, final Validator validator) {
final ClientConfig config = new ClientConfig();
for (Object singleton : this.singletons) {
config.register(singleton);
}
for (Class<?> provider : this.providers) {
config.register(provider);
}
config.register(new JacksonBinder(objectMapper));
config.register(new HibernateValidationFeature(validator));
for (Map.Entry<String, Object> property : this.properties.entrySet()) {
config.property(property.getKey(), property.getValue());
}
config.register(new DropwizardExecutorProvider(threadPool, shutdownGracePeriod));
if (connectorProvider == null) {
final ConfiguredCloseableHttpClient apacheHttpClient = apacheHttpClientBuilder.buildWithDefaultRequestConfiguration(name);
connectorProvider = (client, runtimeConfig) -> new DropwizardApacheConnector(apacheHttpClient.getClient(), apacheHttpClient.getDefaultRequestConfig(), configuration.isChunkedEncodingEnabled());
}
config.connectorProvider(connectorProvider);
return config;
}
use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class EncodingFilterTest method testContentEncodingSkippedForNoEntity.
@Test
public void testContentEncodingSkippedForNoEntity() {
Client client = ClientBuilder.newClient(new ClientConfig(EncodingFilter.class, GZipEncoder.class, DeflateEncoder.class).property(ClientProperties.USE_ENCODING, "gzip").connectorProvider(new TestConnector()));
Invocation.Builder invBuilder = client.target(UriBuilder.fromUri("/").build()).request();
Response r = invBuilder.get();
assertEquals("deflate,gzip,x-gzip", r.getHeaderString(ACCEPT_ENCODING));
assertNull(r.getHeaderString(CONTENT_ENCODING));
}
use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class HttpBasicAuthFilterTest method testGet.
@Test
public void testGet() {
Client client = ClientBuilder.newClient(new ClientConfig(HttpAuthenticationFeature.basic("Uzivatelske jmeno", "Heslo")).connectorProvider(new TestConnector()));
Invocation.Builder invBuilder = client.target(UriBuilder.fromUri("/").build()).request();
Response r = invBuilder.get();
assertEquals("Basic " + Base64.encodeAsString("Uzivatelske jmeno:Heslo"), r.getHeaderString(HttpHeaders.AUTHORIZATION));
}
use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class HttpBasicAuthFilterTest method testBlankUsernamePassword.
@Test
public void testBlankUsernamePassword() {
Client client = ClientBuilder.newClient(new ClientConfig(HttpAuthenticationFeature.basic("", "")).connectorProvider(new TestConnector()));
Invocation.Builder invBuilder = client.target(UriBuilder.fromUri("/").build()).request();
Response r = invBuilder.get();
assertEquals("Basic " + Base64.encodeAsString(":"), r.getHeaderString(HttpHeaders.AUTHORIZATION));
}
use of org.glassfish.jersey.client.ClientConfig in project jersey by jersey.
the class CsrfProtectionFilterTest method setUp.
@Before
public void setUp() {
Client client = ClientBuilder.newClient(new ClientConfig(CsrfProtectionFilter.class).connectorProvider(new TestConnector()));
invBuilder = client.target(UriBuilder.fromUri("/").build()).request();
}
Aggregations