Example usage for org.apache.http.params CoreConnectionPNames MAX_LINE_LENGTH

List of usage examples for org.apache.http.params CoreConnectionPNames MAX_LINE_LENGTH

Introduction

In this page you can find the example usage for org.apache.http.params CoreConnectionPNames MAX_LINE_LENGTH.

Prototype

String MAX_LINE_LENGTH

To view the source code for org.apache.http.params CoreConnectionPNames MAX_LINE_LENGTH.

Click Source Link

Usage

From source file:org.openrepose.core.services.httpclient.impl.HttpConnectionPoolProvider.java

public static HttpClient genClient(PoolType poolConf) {

    PoolingClientConnectionManager cm = new PoolingClientConnectionManager();

    cm.setDefaultMaxPerRoute(poolConf.getHttpConnManagerMaxPerRoute());
    cm.setMaxTotal(poolConf.getHttpConnManagerMaxTotal());

    //Set all the params up front, instead of mutating them? Maybe this matters
    HttpParams params = new BasicHttpParams();
    params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES);
    params.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
    params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, poolConf.getHttpSocketTimeout());
    params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, poolConf.getHttpConnectionTimeout());
    params.setParameter(CoreConnectionPNames.TCP_NODELAY, poolConf.isHttpTcpNodelay());
    params.setParameter(CoreConnectionPNames.MAX_HEADER_COUNT, poolConf.getHttpConnectionMaxHeaderCount());
    params.setParameter(CoreConnectionPNames.MAX_LINE_LENGTH, poolConf.getHttpConnectionMaxLineLength());
    params.setParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, poolConf.getHttpSocketBufferSize());
    params.setBooleanParameter(CHUNKED_ENCODING_PARAM, poolConf.isChunkedEncoding());

    final String uuid = UUID.randomUUID().toString();
    params.setParameter(CLIENT_INSTANCE_ID, uuid);

    //Pass in the params and the connection manager
    DefaultHttpClient client = new DefaultHttpClient(cm, params);

    SSLContext sslContext = ProxyUtilities.getTrustingSslContext();
    SSLSocketFactory ssf = new SSLSocketFactory(sslContext, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    SchemeRegistry registry = cm.getSchemeRegistry();
    Scheme scheme = new Scheme("https", DEFAULT_HTTPS_PORT, ssf);
    registry.register(scheme);//from w w  w  .  j a v a 2s  .com

    client.setKeepAliveStrategy(new ConnectionKeepAliveWithTimeoutStrategy(poolConf.getKeepaliveTimeout()));

    LOG.info("HTTP connection pool {} with instance id {} has been created", poolConf.getId(), uuid);

    return client;
}

From source file:com.subgraph.vega.internal.http.proxy.VegaHttpRequestParser.java

public VegaHttpRequestParser(final VegaHttpServerConnection conn, final SessionInputBuffer buffer,
        final LineParser parser, final HttpRequestFactory requestFactory, final HttpParams params) {
    if (requestFactory == null) {
        throw new IllegalArgumentException("Request factory may not be null");
    }/*from   w w  w  .  j a  va 2  s .co m*/
    this.conn = conn;
    this.sessionBuffer = buffer;
    this.lineParser = parser;
    this.requestFactory = requestFactory;
    this.lineBuf = new CharArrayBuffer(128);
    this.maxHeaderCount = params.getIntParameter(CoreConnectionPNames.MAX_HEADER_COUNT, -1);
    this.maxLineLen = params.getIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, -1);
}

From source file:org.vietspider.net.apache.DefaultResponseParser.java

public DefaultResponseParser(final SessionInputBuffer buffer, final LineParser parser,
        final HttpResponseFactory responseFactory, final HttpParams params) {
    if (buffer == null) {
        throw new IllegalArgumentException("Session input buffer may not be null");
    }/*from  w  ww  .  j  a  v  a  2  s . co  m*/
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }

    this._sessionBuffer = buffer;
    //    this.timeoutSocket = params.getBooleanParameter("vietspider.socket.timeout", false);
    this.maxHeaderCount = params.getIntParameter(CoreConnectionPNames.MAX_HEADER_COUNT, -1);
    this.maxLineLen = params.getIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, -1);
    this.lineParser = (parser != null) ? parser : BasicLineParser.DEFAULT;

    if (responseFactory == null) {
        throw new IllegalArgumentException("Response factory may not be null");
    }

    this.responseFactory = responseFactory;
    this.lineBuf = new CharArrayBuffer(128);
    this.maxGarbageLines = params.getIntParameter(ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE,
            Integer.MAX_VALUE);
}

From source file:org.vietspider.net.apache.AbstractSessionInputBuffer.java

protected void init(final InputStream _instream, int buffersize, final HttpParams params) {
    if (_instream == null) {
        throw new IllegalArgumentException("Input stream may not be null");
    }//  w w  w  .j  av  a  2s.c  o  m
    if (buffersize <= 0) {
        throw new IllegalArgumentException("Buffer size may not be negative or zero");
    }
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    this.instream = _instream;
    this.buffer = new byte[buffersize];
    this.bufferpos = 0;
    this.bufferlen = 0;
    this.linebuffer = new ByteArrayBuffer(buffersize);
    this.charset = HttpProtocolParams.getHttpElementCharset(params);
    //    this.timeoutSocket = params.getBooleanParameter("vietspider.socket.timeout", false);
    this.ascii = this.charset.equalsIgnoreCase(HTTP.US_ASCII) || this.charset.equalsIgnoreCase(HTTP.ASCII);
    this.maxLineLen = params.getIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, -1);
    this.metrics = new HttpTransportMetricsImpl();
}

From source file:org.apache.droids.protocol.http.DroidsHttpClient.java

@Override
protected HttpParams createHttpParams() {
    HttpParams params = new BasicHttpParams();
    params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
    params.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, HTTP.DEFAULT_CONTENT_CHARSET);
    params.setParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
    params.setParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false);
    params.setIntParameter(CoreConnectionPNames.MAX_HEADER_COUNT, 256);
    params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 5 * 1024);
    params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 20000);
    params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 20000);
    params.setParameter(CoreConnectionPNames.TCP_NODELAY, false);
    //params.setLongParameter(MAX_BODY_LENGTH, 512 * 1024);
    return params;
}

From source file:org.mycard.net.network.AndroidHttpClientConnection.java

/***
 * Bind socket and set HttpParams to AndroidHttpClientConnection
 * @param socket outgoing socket//from  w  ww  . ja v a2s  . c o  m
 * @param params HttpParams
 * @throws IOException
  */
public void bind(final Socket socket, final HttpParams params) throws IOException {
    if (socket == null) {
        throw new IllegalArgumentException("Socket may not be null");
    }
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    assertNotOpen();
    socket.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
    socket.setSoTimeout(HttpConnectionParams.getSoTimeout(params));

    int linger = HttpConnectionParams.getLinger(params);
    if (linger >= 0) {
        socket.setSoLinger(linger > 0, linger);
    }
    this.socket = socket;

    int buffersize = HttpConnectionParams.getSocketBufferSize(params);
    this.inbuffer = new SocketInputBuffer(socket, buffersize, params);
    this.outbuffer = new SocketOutputBuffer(socket, buffersize, params);

    maxHeaderCount = params.getIntParameter(CoreConnectionPNames.MAX_HEADER_COUNT, -1);
    maxLineLength = params.getIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, -1);

    this.requestWriter = new HttpRequestWriter(outbuffer, null, params);

    this.metrics = new HttpConnectionMetricsImpl(inbuffer.getMetrics(), outbuffer.getMetrics());

    this.open = true;
}