prevent creation of auth schema factories every time a servlet is called

pull/402/head
Michael Peter Christen 4 years ago
parent fcc9386ed3
commit eea2d71851

@ -145,6 +145,11 @@ public class HTTPClient {
public static final AtomicBoolean ENABLE_SNI_EXTENSION = new AtomicBoolean( public static final AtomicBoolean ENABLE_SNI_EXTENSION = new AtomicBoolean(
Boolean.parseBoolean(System.getProperty("jsse.enableSNIExtension", Boolean.toString(ENABLE_SNI_EXTENSION_DEFAULT)))); Boolean.parseBoolean(System.getProperty("jsse.enableSNIExtension", Boolean.toString(ENABLE_SNI_EXTENSION_DEFAULT))));
// digest factories
private final BasicSchemeFactory BASIC_SCHEME_FACTORY = new BasicSchemeFactory();
private final YaCyDigestSchemeFactory YACY_DIGEST_SCHEME_FACTORY = new YaCyDigestSchemeFactory();
/** /**
* Background daemon thread evicting expired idle connections from the pool. * Background daemon thread evicting expired idle connections from the pool.
* This may be eventually already done by the pool itself on connection request, * This may be eventually already done by the pool itself on connection request,
@ -443,11 +448,10 @@ public class HTTPClient {
/* Use the custom YaCyDigestScheme for HTTP Digest Authentication */ /* Use the custom YaCyDigestScheme for HTTP Digest Authentication */
final Lookup<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create() final Lookup<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
.register(AuthSchemes.BASIC, new BasicSchemeFactory()) .register(AuthSchemes.BASIC, BASIC_SCHEME_FACTORY)
.register(AuthSchemes.DIGEST, new YaCyDigestSchemeFactory()) .register(AuthSchemes.DIGEST, YACY_DIGEST_SCHEME_FACTORY)
.build(); .build();
CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider) CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider)
.setDefaultAuthSchemeRegistry(authSchemeRegistry).build(); .setDefaultAuthSchemeRegistry(authSchemeRegistry).build();
byte[] content = null; byte[] content = null;
@ -654,11 +658,10 @@ public class HTTPClient {
/* Use the custom YaCyDigestScheme for HTTP Digest Authentication */ /* Use the custom YaCyDigestScheme for HTTP Digest Authentication */
final Lookup<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create() final Lookup<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
.register(AuthSchemes.BASIC, new BasicSchemeFactory()) .register(AuthSchemes.BASIC, BASIC_SCHEME_FACTORY)
.register(AuthSchemes.DIGEST, new YaCyDigestSchemeFactory()) .register(AuthSchemes.DIGEST, YACY_DIGEST_SCHEME_FACTORY)
.build(); .build();
CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider) CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider)
.setDefaultAuthSchemeRegistry(authSchemeRegistry).build(); .setDefaultAuthSchemeRegistry(authSchemeRegistry).build();

Loading…
Cancel
Save