@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class UnixConnectionSocketFactory implements ConnectionSocketFactory {
@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class NpipeConnectionSocketFactory implements ConnectionSocketFactory {
@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class UnixConnectionSocketFactory implements ConnectionSocketFactory {
/** * Noop implementation of {@link UserTokenHandler} that always returns {@code null}. * * @since 4.3 */ @Contract(threading = ThreadingBehavior.IMMUTABLE) public class NoopUserTokenHandler implements UserTokenHandler { public static final NoopUserTokenHandler INSTANCE = new NoopUserTokenHandler(); @Override public Object getUserToken(final HttpContext context) { return null; } }
/** * Handler for HttpOnly attribute * * @author Alexis Thaveau on 20/10/14. */ @Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class HttpOnlyHandler extends AbstractCookieAttributeHandler { public HttpOnlyHandler() { super(); } public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { Args.notNull(cookie, "Cookie"); ((BasicClientCookie) cookie).setAttribute(CookieUtil.HTTP_ONLY_ATTR, ""); } }
/** * A strategy that never re-uses a connection. * * @since 4.0 */ @Contract(threading = ThreadingBehavior.IMMUTABLE) public class NoConnectionReuseStrategy implements ConnectionReuseStrategy { public static final NoConnectionReuseStrategy INSTANCE = new NoConnectionReuseStrategy(); public NoConnectionReuseStrategy() { super(); } @Override public boolean keepAlive(final HttpResponse response, final HttpContext context) { return false; } }
/** * Default {@link org.apache.http.client.AuthenticationStrategy} implementation * for proxy host authentication. * * @since 4.2 */ @Contract(threading = ThreadingBehavior.IMMUTABLE) public class ProxyAuthenticationStrategy extends AuthenticationStrategyImpl { public static final ProxyAuthenticationStrategy INSTANCE = new ProxyAuthenticationStrategy(); public ProxyAuthenticationStrategy() { super(HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED, AUTH.PROXY_AUTH); } @Override Collection<String> getPreferredAuthSchemes(final RequestConfig config) { return config.getProxyPreferredAuthSchemes(); } }
/** * * @since 4.0 */ @Contract(threading = ThreadingBehavior.IMMUTABLE) public abstract class AbstractCookieAttributeHandler implements CookieAttributeHandler { @Override public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException { // Do nothing } @Override public boolean match(final Cookie cookie, final CookieOrigin origin) { // Always match return true; } }
/** * Default {@link org.apache.http.client.AuthenticationStrategy} implementation * for proxy host authentication. * * @since 4.2 */ @Contract(threading = ThreadingBehavior.IMMUTABLE) public class TargetAuthenticationStrategy extends AuthenticationStrategyImpl { public static final TargetAuthenticationStrategy INSTANCE = new TargetAuthenticationStrategy(); public TargetAuthenticationStrategy() { super(HttpStatus.SC_UNAUTHORIZED, AUTH.WWW_AUTH); } @Override Collection<String> getPreferredAuthSchemes(final RequestConfig config) { return config.getTargetPreferredAuthSchemes(); } }
/** * * @since 4.0 */ @Contract(threading = ThreadingBehavior.IMMUTABLE) public class BasicCommentHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler { public BasicCommentHandler() { super(); } @Override public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { Args.notNull(cookie, "Cookie"); cookie.setComment(value); } @Override public String getAttributeName() { return ClientCookie.COMMENT_ATTR; } }
/** * {@link AuthSchemeProvider} implementation that creates and initializes * {@link NTLMScheme} instances configured to use the default {@link NTLMEngine} * implementation. * * @since 4.1 */ @Contract(threading = ThreadingBehavior.IMMUTABLE) @SuppressWarnings("deprecation") public class NTLMSchemeFactory implements AuthSchemeFactory, AuthSchemeProvider { @Override public AuthScheme newInstance(final HttpParams params) { return new NTLMScheme(); } @Override public AuthScheme create(final HttpContext context) { return new NTLMScheme(); } }
/** * The NO_OP HostnameVerifier essentially turns hostname verification * off. This implementation is a no-op, and never throws the SSLException. * * @since 4.4 */ @Contract(threading = ThreadingBehavior.IMMUTABLE) public class NoopHostnameVerifier implements HostnameVerifier { public static final NoopHostnameVerifier INSTANCE = new NoopHostnameVerifier(); @Override public boolean verify(final String s, final SSLSession sslSession) { return true; } @Override public final String toString() { return "NO_OP"; } }
/** * Default factory for request message writers. * * @since 4.3 */ @Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class DefaultHttpRequestWriterFactory implements HttpMessageWriterFactory<HttpRequest> { public static final DefaultHttpRequestWriterFactory INSTANCE = new DefaultHttpRequestWriterFactory(); private final LineFormatter lineFormatter; public DefaultHttpRequestWriterFactory(final LineFormatter lineFormatter) { super(); this.lineFormatter = lineFormatter != null ? lineFormatter : BasicLineFormatter.INSTANCE; } public DefaultHttpRequestWriterFactory() { this(null); } @Override public HttpMessageWriter<HttpRequest> create(final SessionOutputBuffer buffer) { return new DefaultHttpRequestWriter(buffer, lineFormatter); } }
/** * A BrowserCompatSpecFactory that registers HttpOnly handler and disables path validation. * * @author Alexis Thaveau on 21/10/14. */ @Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class CustomBrowserCompatSpecFactory implements CookieSpecProvider { /** * Constant for HttpClient configuration. */ public static final String CUSTOM_BROWSER_COMPATIBILITY = "custom_browser_compatibility"; @Override public CookieSpec create(final HttpContext context) { // SecurityLevel.SECURITYLEVEL_IE_MEDIUM disables path validation AbstractCookieSpec cookieSpec = new BrowserCompatSpec(null, SecurityLevel.SECURITYLEVEL_IE_MEDIUM); cookieSpec.registerAttribHandler(CookieUtil.HTTP_ONLY_ATTR, new HttpOnlyHandler()); return cookieSpec; } }
/** * {@link AuthSchemeProvider} implementation that creates and initializes * {@link WindowsNegotiateScheme} using JNA to Negotiate credentials * <p> * EXPERIMENTAL * </p> * * @since 4.4 */ @Contract(threading = ThreadingBehavior.IMMUTABLE) public class WindowsNegotiateSchemeFactory implements AuthSchemeProvider { private final String servicePrincipalName; public WindowsNegotiateSchemeFactory(final String servicePrincipalName) { super(); this.servicePrincipalName = servicePrincipalName; } @Override public AuthScheme create(final HttpContext context) { return new WindowsNegotiateScheme(AuthSchemes.SPNEGO, servicePrincipalName); } }
/** * {@link AuthSchemeProvider} implementation that creates and initializes * {@link WindowsNegotiateScheme} using JNA to implement NTLM * <p> * EXPERIMENTAL * </p> * * @since 4.4 */ @Contract(threading = ThreadingBehavior.IMMUTABLE) public class WindowsNTLMSchemeFactory implements AuthSchemeProvider { private final String servicePrincipalName; public WindowsNTLMSchemeFactory(final String servicePrincipalName) { super(); this.servicePrincipalName = servicePrincipalName; } @Override public AuthScheme create(final HttpContext context) { return new WindowsNegotiateScheme(AuthSchemes.NTLM, servicePrincipalName); } }
/** * Default factory for response message writers. * * @since 4.3 */ @Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class DefaultHttpResponseWriterFactory implements HttpMessageWriterFactory<HttpResponse> { public static final DefaultHttpResponseWriterFactory INSTANCE = new DefaultHttpResponseWriterFactory(); private final LineFormatter lineFormatter; public DefaultHttpResponseWriterFactory(final LineFormatter lineFormatter) { super(); this.lineFormatter = lineFormatter != null ? lineFormatter : BasicLineFormatter.INSTANCE; } public DefaultHttpResponseWriterFactory() { this(null); } @Override public HttpMessageWriter<HttpResponse> create(final SessionOutputBuffer buffer) { return new DefaultHttpResponseWriter(buffer, lineFormatter); } }
/** * {@link InputStreamFactory} for handling Deflate Content Coded responses. * * @since 4.5.4 */ @Contract(threading = ThreadingBehavior.IMMUTABLE) public class DeflateInputStreamFactory implements InputStreamFactory { /** * Singleton instance. */ private static final DeflateInputStreamFactory INSTANCE = new DeflateInputStreamFactory(); /** * Gets the singleton instance. * * @return the singleton instance. */ public static DeflateInputStreamFactory getInstance() { return INSTANCE; } @Override public InputStream create(final InputStream inputStream) throws IOException { return new DeflateInputStream(inputStream); } }
/** * Implementation of an {@link org.apache.http.conn.routing.HttpRoutePlanner} * that routes requests through a default proxy. * * @since 4.3 */ @Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class DefaultProxyRoutePlanner extends DefaultRoutePlanner { private final HttpHost proxy; public DefaultProxyRoutePlanner(final HttpHost proxy, final SchemePortResolver schemePortResolver) { super(schemePortResolver); this.proxy = Args.notNull(proxy, "Proxy host"); } public DefaultProxyRoutePlanner(final HttpHost proxy) { this(proxy, null); } @Override protected HttpHost determineProxy( final HttpHost target, final HttpRequest request, final HttpContext context) throws HttpException { return proxy; } }
/** * Decorator for {@link ContentLengthStrategy} implementations that disallows the use of * identity transfer encoding. * * @since 4.2 */ @Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL) public class DisallowIdentityContentLengthStrategy implements ContentLengthStrategy { public static final DisallowIdentityContentLengthStrategy INSTANCE = new DisallowIdentityContentLengthStrategy(new LaxContentLengthStrategy(0)); private final ContentLengthStrategy contentLengthStrategy; public DisallowIdentityContentLengthStrategy(final ContentLengthStrategy contentLengthStrategy) { super(); this.contentLengthStrategy = contentLengthStrategy; } @Override public long determineLength(final HttpMessage message) throws HttpException { final long result = this.contentLengthStrategy.determineLength(message); if (result == ContentLengthStrategy.IDENTITY) { throw new ProtocolException("Identity transfer encoding cannot be used"); } return result; } }