org.apache.http.io.HttpMessageWriterFactory Java Examples

The following examples show how to use org.apache.http.io.HttpMessageWriterFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MockIpdServer.java    From deprecated-security-advanced-modules with Apache License 2.0 5 votes vote down vote up
public SSLTestHttpServerConnection(final int buffersize, final int fragmentSizeHint,
		final CharsetDecoder chardecoder, final CharsetEncoder charencoder,
		final MessageConstraints constraints, final ContentLengthStrategy incomingContentStrategy,
		final ContentLengthStrategy outgoingContentStrategy,
		final HttpMessageParserFactory<HttpRequest> requestParserFactory,
		final HttpMessageWriterFactory<HttpResponse> responseWriterFactory) {
	super(buffersize, fragmentSizeHint, chardecoder, charencoder, constraints, incomingContentStrategy,
			outgoingContentStrategy, requestParserFactory, responseWriterFactory);
}
 
Example #2
Source File: MockSamlIdpServer.java    From deprecated-security-advanced-modules with Apache License 2.0 5 votes vote down vote up
public SSLTestHttpServerConnection(final int buffersize, final int fragmentSizeHint,
        final CharsetDecoder chardecoder, final CharsetEncoder charencoder,
        final MessageConstraints constraints, final ContentLengthStrategy incomingContentStrategy,
        final ContentLengthStrategy outgoingContentStrategy,
        final HttpMessageParserFactory<HttpRequest> requestParserFactory,
        final HttpMessageWriterFactory<HttpResponse> responseWriterFactory) {
    super(buffersize, fragmentSizeHint, chardecoder, charencoder, constraints, incomingContentStrategy,
            outgoingContentStrategy, requestParserFactory, responseWriterFactory);
}
 
Example #3
Source File: SettingsBasedSSLConfiguratorTest.java    From deprecated-security-advanced-modules with Apache License 2.0 5 votes vote down vote up
public SSLTestHttpServerConnection(final int buffersize, final int fragmentSizeHint,
        final CharsetDecoder chardecoder, final CharsetEncoder charencoder,
        final MessageConstraints constraints, final ContentLengthStrategy incomingContentStrategy,
        final ContentLengthStrategy outgoingContentStrategy,
        final HttpMessageParserFactory<HttpRequest> requestParserFactory,
        final HttpMessageWriterFactory<HttpResponse> responseWriterFactory) {
    super(buffersize, fragmentSizeHint, chardecoder, charencoder, constraints, incomingContentStrategy,
            outgoingContentStrategy, requestParserFactory, responseWriterFactory);
}
 
Example #4
Source File: TracingManagedHttpClientConnectionFactory.java    From caravan with Apache License 2.0 5 votes vote down vote up
public TracingManagedHttpClientConnectionFactory(final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
        final HttpMessageParserFactory<HttpResponse> responseParserFactory, final ContentLengthStrategy incomingContentStrategy,
        final ContentLengthStrategy outgoingContentStrategy, LogFunc logFunc) {
    super();
    this.requestWriterFactory = requestWriterFactory != null ? requestWriterFactory : DefaultHttpRequestWriterFactory.INSTANCE;
    this.responseParserFactory = responseParserFactory != null ? responseParserFactory : DefaultHttpResponseParserFactory.INSTANCE;
    this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy : LaxContentLengthStrategy.INSTANCE;
    this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy : StrictContentLengthStrategy.INSTANCE;
    this.logFunc = logFunc != null ? logFunc : DefaultLogFunc.DEFAULT;
}
 
Example #5
Source File: TracingManagedHttpClientConnection.java    From caravan with Apache License 2.0 5 votes vote down vote up
public TracingManagedHttpClientConnection(final String id, final int buffersize, final int fragmentSizeHint, final CharsetDecoder chardecoder,
        final CharsetEncoder charencoder, final MessageConstraints constraints, final ContentLengthStrategy incomingContentStrategy,
        final ContentLengthStrategy outgoingContentStrategy, final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
        final HttpMessageParserFactory<HttpResponse> responseParserFactory, LogFunc logFunc) {
    super(id, buffersize, fragmentSizeHint, chardecoder, charencoder, constraints, incomingContentStrategy, outgoingContentStrategy, requestWriterFactory,
            responseParserFactory);

    _logFunc = logFunc;

    hackBufferFields(buffersize, constraints, chardecoder, responseParserFactory);
}
 
Example #6
Source File: HttpSyncClient.java    From Almost-Famous with MIT License 4 votes vote down vote up
public CloseableHttpClient createSyncClient(boolean proxy)
        throws Exception {

    HttpMessageParserFactory<HttpResponse> responseParserFactory = new DefaultHttpResponseParserFactory();
    HttpMessageWriterFactory<HttpRequest> requestWriterFactory = new DefaultHttpRequestWriterFactory();

    HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory = new ManagedHttpClientConnectionFactory(
            requestWriterFactory, responseParserFactory);

    SSLContext sslcontext = SSLContexts.createSystemDefault();

    Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
            .register("http", PlainConnectionSocketFactory.INSTANCE)
            .register("https", new SSLConnectionSocketFactory(sslcontext))
            .build();

    // Create a connection manager with custom configuration.
    PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(
            socketFactoryRegistry, connFactory);

    // Create socket configuration
    SocketConfig socketConfig = SocketConfig.custom()
            .setTcpNoDelay(true)
            .build();
    // Configure the connection manager to use socket configuration either
    // by default or for a specific host.
    connManager.setDefaultSocketConfig(socketConfig);
    connManager.setSocketConfig(new HttpHost("somehost", 80), socketConfig);
    // Validate connections after 1 sec of inactivity
    connManager.setValidateAfterInactivity(1000);

    // Create message constraints
    MessageConstraints messageConstraints = MessageConstraints.custom()
            .setMaxHeaderCount(200)
            .setMaxLineLength(2000)
            .build();
    // Create connection configuration
    ConnectionConfig connectionConfig = ConnectionConfig.custom()
            .setMalformedInputAction(CodingErrorAction.IGNORE)
            .setUnmappableInputAction(CodingErrorAction.IGNORE)
            .setCharset(Consts.UTF_8)
            .setMessageConstraints(messageConstraints)
            .build();
    // Configure the connection manager to use connection configuration either
    // by default or for a specific host.
    connManager.setDefaultConnectionConfig(connectionConfig);

    // Configure total max or per route limits for persistent connections
    // that can be kept in the pool or leased by the connection manager.
    connManager.setMaxTotal(poolSize);
    if (maxPerRoute > 0) {
        connManager.setDefaultMaxPerRoute(maxPerRoute);
    } else {
        connManager.setDefaultMaxPerRoute(10);
    }

    // Use custom cookie store if necessary.
    CookieStore cookieStore = new BasicCookieStore();
    // Use custom credentials provider if necessary.
    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    // Create global request configuration
    RequestConfig defaultRequestConfig = RequestConfig.custom()
            .setConnectTimeout(connectTimeout)
            .setSocketTimeout(socketTimeout)
            .setConnectionRequestTimeout(connectionRequestTimeout)
            .setCookieSpec(CookieSpecs.DEFAULT)
            .setExpectContinueEnabled(true)
            .setTargetPreferredAuthSchemes(Arrays.asList(AuthSchemes.NTLM, AuthSchemes.DIGEST))
            .setProxyPreferredAuthSchemes(Arrays.asList(AuthSchemes.BASIC))
            .build();

    // Create an HttpClient with the given custom dependencies and configuration.
    CloseableHttpClient httpclient = HttpClients.custom()
            .setConnectionManager(connManager)
            .setDefaultCookieStore(cookieStore)
            .setDefaultCredentialsProvider(credentialsProvider)
            .setDefaultRequestConfig(defaultRequestConfig)
            .build();

    return httpclient;
}
 
Example #7
Source File: TracingManagedHttpClientConnectionFactory.java    From caravan with Apache License 2.0 4 votes vote down vote up
public TracingManagedHttpClientConnectionFactory(final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
        final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
    this(requestWriterFactory, responseParserFactory, null, null, null);
}