org.apache.http.config.MessageConstraints Java Examples

The following examples show how to use org.apache.http.config.MessageConstraints. 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: TracingManagedHttpClientConnection.java    From caravan with Apache License 2.0 6 votes vote down vote up
private void hackBufferFields(int buffersize, MessageConstraints messageConstraints, CharsetDecoder chardecoder,
        HttpMessageParserFactory<HttpResponse> responseParserFactory) {
    if (!_hackFiledGot)
        return;

    try {
        SessionInputBufferImpl old = (SessionInputBufferImpl) _sessionInputBufferField.get(this);
        _sessionInputBufferImpl = new TracingSessionInputBufferImpl((HttpTransportMetricsImpl) old.getMetrics(), buffersize, -1,
                messageConstraints != null ? messageConstraints : MessageConstraints.DEFAULT, chardecoder, _logFunc);
        _sessionInputBufferField.set(this, _sessionInputBufferImpl);

        HttpMessageParser<HttpResponse> responseParser = (responseParserFactory != null ? responseParserFactory : DefaultHttpResponseParserFactory.INSTANCE)
                .create(getSessionInputBuffer(), messageConstraints);
        _responseParserField.set(this, responseParser);
    } catch (Exception ex) {
        _logger.warn("Hack fields failed.", ex);
    }
}
 
Example #2
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 #3
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 #4
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 #5
Source File: TracingSessionInputBufferImpl.java    From caravan with Apache License 2.0 5 votes vote down vote up
public TracingSessionInputBufferImpl(final HttpTransportMetricsImpl metrics, final int buffersize, final int minChunkLimit,
        final MessageConstraints constraints, final CharsetDecoder chardecoder, LogFunc logFunc) {
    super(metrics, buffersize, minChunkLimit, constraints, chardecoder);

    _logFunc = logFunc;
    _firstRead = true;
}
 
Example #6
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 #7
Source File: ExtendedHttpClientBuilder.java    From lavaplayer with Apache License 2.0 5 votes vote down vote up
public GarbageAllergicHttpResponseParser(
    SessionInputBuffer buffer,
    LineParser lineParser,
    HttpResponseFactory responseFactory,
    MessageConstraints constraints
) {
  super(buffer, lineParser, responseFactory, constraints);
}
 
Example #8
Source File: HttpClientPool.java    From message_interface with MIT License 5 votes vote down vote up
private static CloseableHttpClient client() {
    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
    cm.setDefaultMaxPerRoute(100);
    cm.setMaxTotal(400);

    MessageConstraints messageConstraints = MessageConstraints.custom()
            .setMaxHeaderCount(200)
            .setMaxLineLength(2000)
            .build();

    ConnectionConfig connectionConfig = ConnectionConfig.custom()
            .setMalformedInputAction(CodingErrorAction.IGNORE)
            .setUnmappableInputAction(CodingErrorAction.IGNORE)
            .setCharset(Consts.UTF_8)
            .setMessageConstraints(messageConstraints)
            .build();

    RequestConfig defaultRequestConfig = RequestConfig.custom()
            .setSocketTimeout(5000)
            .setConnectTimeout(5000)
            .setConnectionRequestTimeout(5000)
            .build();

    cm.setDefaultConnectionConfig(connectionConfig);

    return HttpClients.custom()
            .setConnectionManager(cm)
            .setDefaultRequestConfig(defaultRequestConfig)
            .build();
}
 
Example #9
Source File: SimpleUrlContentReader.java    From cosmo with Apache License 2.0 5 votes vote down vote up
private CloseableHttpClient buildClient(int timeoutInMillis, URL url) {
    RequestConfig config = RequestConfig.custom().setConnectionRequestTimeout(timeoutInMillis)
            .setConnectTimeout(timeoutInMillis).setRedirectsEnabled(true).setMaxRedirects(MAX_REDIRECTS)
            .setProxy(this.proxyFactory.getProxy(url)).build();
    return HttpClientBuilder.create().setDefaultRequestConfig(config)
            .setDefaultConnectionConfig(
                    ConnectionConfig
                            .custom().setMessageConstraints(MessageConstraints.custom()
                                    .setMaxHeaderCount(MAX_HEADER_COUNT).setMaxLineLength(MAX_LINE_LENGTH).build())
                            .build())
            .build();
}