You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Arul Dhesiaseelan <ar...@acm.org> on 2013/11/13 05:49:19 UTC

CoreConnectionPNames.MIN_CHUNK_LIMIT equivalent in 4.3.1

Hi,

CoreConnectionPNames is deprecated. I could not find MIN_CHUNK_LIMIT
configuration in 4.3.1. The closest I can see is
ConnectionConfig.bufferSize. Not sure if they are the same.

Any idea?

Thanks,
Arul

Re: CoreConnectionPNames.MIN_CHUNK_LIMIT equivalent in 4.3.1

Posted by ARul <ar...@acm.org>.
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 <ol...@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
>
>

Re: CoreConnectionPNames.MIN_CHUNK_LIMIT equivalent in 4.3.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
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


Re: CoreConnectionPNames.MIN_CHUNK_LIMIT equivalent in 4.3.1

Posted by ARul <ar...@acm.org>.
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? Is there a way to configure this
per-request instead of client?

- ARul






On Wed, Nov 13, 2013 at 8:29 AM, Arul Dhesiaseelan <ar...@acm.org> wrote:

> Thanks Oleg for clearing this up.
>
>
> On Wed, Nov 13, 2013 at 7:06 AM, Oleg Kalnichevski <ol...@apache.org>wrote:
>
>> On Wed, 2013-11-13 at 06:54 -1000, Arul Dhesiaseelan wrote:
>> > Using chunked encoding to write the entity. So, this property is not
>> > intended to control the chunk size of the entity?
>> >
>>
>> No, it is not. I admit that javadocs may be unclear about it but I did
>> try to describe its purpose to my best abilities.
>>
>> If you want to change the default chunk size from 2048 to something else
>> you should be looking at the BHttpConnectionBase#createOutputStream
>> method.
>>
>> Oleg
>>
>> > - Arul
>> >
>> >
>> > On Wed, Nov 13, 2013 at 6:43 AM, Oleg Kalnichevski <ol...@apache.org>
>> wrote:
>> >
>> > > On Wed, 2013-11-13 at 06:32 -1000, Arul Dhesiaseelan wrote:
>> > > > Hi Oleg,
>> > > >
>> > > > Using it to control the chunk size on the Client, which can be
>> > > configurable.
>> > > >
>> > >
>> > > Chunks of what? MIN_CHUNK_LIMIT has nothing to do with chunk coding.
>> > > Misleading name was one of the reasons why this parameter was
>> > > discontinued.
>> > >
>> > > Oleg
>> > >
>> > > > - Arul
>> > > >
>> > > >
>> > > > On Wed, Nov 13, 2013 at 5:40 AM, Oleg Kalnichevski <
>> olegk@apache.org>
>> > > wrote:
>> > > >
>> > > > > On Tue, 2013-11-12 at 18:49 -1000, Arul Dhesiaseelan wrote:
>> > > > > > Hi,
>> > > > > >
>> > > > > > CoreConnectionPNames is deprecated. I could not find
>> MIN_CHUNK_LIMIT
>> > > > > > configuration in 4.3.1. The closest I can see is
>> > > > > > ConnectionConfig.bufferSize. Not sure if they are the same.
>> > > > > >
>> > > > > > Any idea?
>> > > > > >
>> > > > >
>> > > > > Arul
>> > > > >
>> > > > > There is no direct equivalent of MIN_CHUNK_LIMIT in 4.3. What are
>> you
>> > > > > using this parameter for?
>> > > > >
>> > > > > Oleg
>> > > > >
>> > > > >
>> > > > >
>> > > > >
>> ---------------------------------------------------------------------
>> > > > > To unsubscribe, e-mail:
>> httpclient-users-unsubscribe@hc.apache.org
>> > > > > For additional commands, e-mail:
>> httpclient-users-help@hc.apache.org
>> > > > >
>> > > > >
>> > >
>> > >
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
>> > >
>> > >
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
>

Re: CoreConnectionPNames.MIN_CHUNK_LIMIT equivalent in 4.3.1

Posted by Arul Dhesiaseelan <ar...@acm.org>.
Thanks Oleg for clearing this up.


On Wed, Nov 13, 2013 at 7:06 AM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Wed, 2013-11-13 at 06:54 -1000, Arul Dhesiaseelan wrote:
> > Using chunked encoding to write the entity. So, this property is not
> > intended to control the chunk size of the entity?
> >
>
> No, it is not. I admit that javadocs may be unclear about it but I did
> try to describe its purpose to my best abilities.
>
> If you want to change the default chunk size from 2048 to something else
> you should be looking at the BHttpConnectionBase#createOutputStream
> method.
>
> Oleg
>
> > - Arul
> >
> >
> > On Wed, Nov 13, 2013 at 6:43 AM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> >
> > > On Wed, 2013-11-13 at 06:32 -1000, Arul Dhesiaseelan wrote:
> > > > Hi Oleg,
> > > >
> > > > Using it to control the chunk size on the Client, which can be
> > > configurable.
> > > >
> > >
> > > Chunks of what? MIN_CHUNK_LIMIT has nothing to do with chunk coding.
> > > Misleading name was one of the reasons why this parameter was
> > > discontinued.
> > >
> > > Oleg
> > >
> > > > - Arul
> > > >
> > > >
> > > > On Wed, Nov 13, 2013 at 5:40 AM, Oleg Kalnichevski <olegk@apache.org
> >
> > > wrote:
> > > >
> > > > > On Tue, 2013-11-12 at 18:49 -1000, Arul Dhesiaseelan wrote:
> > > > > > Hi,
> > > > > >
> > > > > > CoreConnectionPNames is deprecated. I could not find
> MIN_CHUNK_LIMIT
> > > > > > configuration in 4.3.1. The closest I can see is
> > > > > > ConnectionConfig.bufferSize. Not sure if they are the same.
> > > > > >
> > > > > > Any idea?
> > > > > >
> > > > >
> > > > > Arul
> > > > >
> > > > > There is no direct equivalent of MIN_CHUNK_LIMIT in 4.3. What are
> you
> > > > > using this parameter for?
> > > > >
> > > > > Oleg
> > > > >
> > > > >
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > > > For additional commands, e-mail:
> httpclient-users-help@hc.apache.org
> > > > >
> > > > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > >
> > >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Re: CoreConnectionPNames.MIN_CHUNK_LIMIT equivalent in 4.3.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2013-11-13 at 06:54 -1000, Arul Dhesiaseelan wrote:
> Using chunked encoding to write the entity. So, this property is not
> intended to control the chunk size of the entity?
> 

No, it is not. I admit that javadocs may be unclear about it but I did
try to describe its purpose to my best abilities. 

If you want to change the default chunk size from 2048 to something else
you should be looking at the BHttpConnectionBase#createOutputStream
method.

Oleg

> - Arul
> 
> 
> On Wed, Nov 13, 2013 at 6:43 AM, Oleg Kalnichevski <ol...@apache.org> wrote:
> 
> > On Wed, 2013-11-13 at 06:32 -1000, Arul Dhesiaseelan wrote:
> > > Hi Oleg,
> > >
> > > Using it to control the chunk size on the Client, which can be
> > configurable.
> > >
> >
> > Chunks of what? MIN_CHUNK_LIMIT has nothing to do with chunk coding.
> > Misleading name was one of the reasons why this parameter was
> > discontinued.
> >
> > Oleg
> >
> > > - Arul
> > >
> > >
> > > On Wed, Nov 13, 2013 at 5:40 AM, Oleg Kalnichevski <ol...@apache.org>
> > wrote:
> > >
> > > > On Tue, 2013-11-12 at 18:49 -1000, Arul Dhesiaseelan wrote:
> > > > > Hi,
> > > > >
> > > > > CoreConnectionPNames is deprecated. I could not find MIN_CHUNK_LIMIT
> > > > > configuration in 4.3.1. The closest I can see is
> > > > > ConnectionConfig.bufferSize. Not sure if they are the same.
> > > > >
> > > > > Any idea?
> > > > >
> > > >
> > > > Arul
> > > >
> > > > There is no direct equivalent of MIN_CHUNK_LIMIT in 4.3. What are you
> > > > using this parameter for?
> > > >
> > > > Oleg
> > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > > >
> > > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >
> >



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: CoreConnectionPNames.MIN_CHUNK_LIMIT equivalent in 4.3.1

Posted by Arul Dhesiaseelan <ar...@acm.org>.
Using chunked encoding to write the entity. So, this property is not
intended to control the chunk size of the entity?

- Arul


On Wed, Nov 13, 2013 at 6:43 AM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Wed, 2013-11-13 at 06:32 -1000, Arul Dhesiaseelan wrote:
> > Hi Oleg,
> >
> > Using it to control the chunk size on the Client, which can be
> configurable.
> >
>
> Chunks of what? MIN_CHUNK_LIMIT has nothing to do with chunk coding.
> Misleading name was one of the reasons why this parameter was
> discontinued.
>
> Oleg
>
> > - Arul
> >
> >
> > On Wed, Nov 13, 2013 at 5:40 AM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> >
> > > On Tue, 2013-11-12 at 18:49 -1000, Arul Dhesiaseelan wrote:
> > > > Hi,
> > > >
> > > > CoreConnectionPNames is deprecated. I could not find MIN_CHUNK_LIMIT
> > > > configuration in 4.3.1. The closest I can see is
> > > > ConnectionConfig.bufferSize. Not sure if they are the same.
> > > >
> > > > Any idea?
> > > >
> > >
> > > Arul
> > >
> > > There is no direct equivalent of MIN_CHUNK_LIMIT in 4.3. What are you
> > > using this parameter for?
> > >
> > > Oleg
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > >
> > >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Re: CoreConnectionPNames.MIN_CHUNK_LIMIT equivalent in 4.3.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2013-11-13 at 06:32 -1000, Arul Dhesiaseelan wrote:
> Hi Oleg,
> 
> Using it to control the chunk size on the Client, which can be configurable.
> 

Chunks of what? MIN_CHUNK_LIMIT has nothing to do with chunk coding.
Misleading name was one of the reasons why this parameter was
discontinued. 

Oleg

> - Arul
> 
> 
> On Wed, Nov 13, 2013 at 5:40 AM, Oleg Kalnichevski <ol...@apache.org> wrote:
> 
> > On Tue, 2013-11-12 at 18:49 -1000, Arul Dhesiaseelan wrote:
> > > Hi,
> > >
> > > CoreConnectionPNames is deprecated. I could not find MIN_CHUNK_LIMIT
> > > configuration in 4.3.1. The closest I can see is
> > > ConnectionConfig.bufferSize. Not sure if they are the same.
> > >
> > > Any idea?
> > >
> >
> > Arul
> >
> > There is no direct equivalent of MIN_CHUNK_LIMIT in 4.3. What are you
> > using this parameter for?
> >
> > Oleg
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >
> >



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: CoreConnectionPNames.MIN_CHUNK_LIMIT equivalent in 4.3.1

Posted by Arul Dhesiaseelan <ar...@acm.org>.
Hi Oleg,

Using it to control the chunk size on the Client, which can be configurable.

- Arul


On Wed, Nov 13, 2013 at 5:40 AM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Tue, 2013-11-12 at 18:49 -1000, Arul Dhesiaseelan wrote:
> > Hi,
> >
> > CoreConnectionPNames is deprecated. I could not find MIN_CHUNK_LIMIT
> > configuration in 4.3.1. The closest I can see is
> > ConnectionConfig.bufferSize. Not sure if they are the same.
> >
> > Any idea?
> >
>
> Arul
>
> There is no direct equivalent of MIN_CHUNK_LIMIT in 4.3. What are you
> using this parameter for?
>
> Oleg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Re: CoreConnectionPNames.MIN_CHUNK_LIMIT equivalent in 4.3.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2013-11-12 at 18:49 -1000, Arul Dhesiaseelan wrote:
> Hi,
> 
> CoreConnectionPNames is deprecated. I could not find MIN_CHUNK_LIMIT
> configuration in 4.3.1. The closest I can see is
> ConnectionConfig.bufferSize. Not sure if they are the same.
> 
> Any idea?
> 

Arul

There is no direct equivalent of MIN_CHUNK_LIMIT in 4.3. What are you
using this parameter for?

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org