hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ARul <ar...@acm.org>
Subject Re: CoreConnectionPNames.MIN_CHUNK_LIMIT equivalent in 4.3.1
Date Mon, 02 Dec 2013 18:02:03 GMT
Ok cool. I was thinking of configuring it at runtime, but I think it may
not be needed.

Thanks!
ARul


On Sun, Dec 1, 2013 at 11:39 PM, Oleg Kalnichevski <olegk@apache.org> wrote:

> On Sun, 2013-12-01 at 13:14 -1000, ARul wrote:
> > Hi Oleg,
> >
> > I was looking into BHttpConnectionBase#createOutputStream method. To
> change
> > the default chunk size (2048), I believe the only way is to implement a
> > custom http client connection and override createOuptputStream(). Here is
> > what I have so far.
> >
> >     public static class CustomManagedHttpClientConnection extends
> > DefaultManagedHttpClientConnection {
> >         private final int chunkSize;
> >
> >         public CustomManagedHttpClientConnection(final String id, final
> int
> > buffersize, final int chunkSize) {
> >             super(id, buffersize);
> >             this.chunkSize = chunkSize;
> >         }
> >
> >         @Override
> >         protected OutputStream createOutputStream(long len,
> > SessionOutputBuffer outbuffer) {
> >             if (len == ContentLengthStrategy.CHUNKED) {
> >                 return new ChunkedOutputStream(chunkSize, outbuffer);
> >             } else if (len == ContentLengthStrategy.IDENTITY) {
> >                 return new IdentityOutputStream(outbuffer);
> >             } else {
> >                 return new ContentLengthOutputStream(outbuffer, len);
> >             }
> >         }
> >     }
> >
> >     public static class CustomManagedHttpClientConnectionFactory extends
> > ManagedHttpClientConnectionFactory {
> >
> >         private final int chunkSize;
> >
> >         public CustomManagedHttpClientConnectionFactory(int chunkSize) {
> >             this.chunkSize = chunkSize;
> >         }
> >
> >         @Override
> >         public ManagedHttpClientConnection create(HttpRoute route,
> > ConnectionConfig config) {
> >             final String id = "http-outgoing-" +
> > Long.toString(COUNTER.getAndIncrement());
> >             return new CustomManagedHttpClientConnection(id,
> > config.getBufferSize(), chunkSize);
> >         }
> >     }
> >
> > Usage:
> >
> >         int chunkSize = 1024;
> >         HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection>
> > connFactory = new CustomManagedHttpClientConnectionFactory(chunkSize);
> >         PoolingHttpClientConnectionManager connManager = new
> > PoolingHttpClientConnectionManager(connFactory);
> >         CloseableHttpClient client =
> HttpClients.createMinimal(connManager);
> >
> > Do you recommend a better approach?
>
> I cannot suggest anything better.
>
> > Is there a way to configure this
> > per-request instead of client?
> >
>
> Why would you want to do that in the first place?
>
> Oleg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message