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 "Jeudy, Guillaume" <gj...@teksystems.com> on 2009/04/17 23:17:45 UTC

Porting Axis2 using commons-httpclient 3.1 to httpclient 4.0

Hi,
 
I'm attempting to port axis2 using commons-httpclient 3.1 to httpclient 4.0 locally. I have a few questions because in some instances I could not find corresponding functionality in 4.0 version.
 
1)  Is httpMethodBase.setDoAuthentication() still required in 4.0 ?

My understanding is that such a switch is no longer required, httpclient 4.0 requests will perform authentication by default if credentials are set and authschemes are properly configured on the HttpClient object.

2) What about the Protocol interface implementations? The HostConfiguration class also disappeared. I now use HttpHost to get equivalent functionality in 4.0. I cannot get equivalent functionality for missing Protocol class in defunct HostConfiguration. Can somebody point in the right direction here?
  
3) Preemptive authentication feature. Before it was easy as:

httpClient.getParams().setAuthenticationPreemptive(true);   what is easiest way to migrate to 4.0 way of doing it ?
  
 4) Reorder auth scheme priority. before you could do things such as:

  List schemes = authenticator.getAuthSchemes();
authPrefs.add(AuthPolicy.BASIC);
authPrefs.add(AuthPolicy.NTLM);
 
httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY,
     authPrefs);

I did not find such customizability in 4.0, any hints? Are all registered auth scheme applied in indefinite order in 4.0?

5) connection management before you had to do:

try {
   httpClient.executeMethod(config, method);
} finally {
     method.releaseConnection();
}

to ensure the connection bound to the HttpMethodBase object is released. In 4.0 version, are connections always released by default whenever httpClient.executeX() is called no matter the outcome? If not please give more insight on how this works in 4.0.
 
Thank you!
-Guillaume
 


____________________________________________________________________________________________________
This electronic mail (including any attachments) may contain information that is privileged, confidential, and/or otherwise protected from disclosure to anyone other than its intended recipient(s). Any dissemination or use of this electronic email or its contents (including any attachments) by persons other than the intended recipient(s) is strictly prohibited. If you have received this message in error, please notify us immediately by reply email so that we may correct our internal records. Please then delete the original message (including any attachments) in its entirety. Thank you.

Re: Porting Axis2 using commons-httpclient 3.1 to httpclient 4.0

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, Apr 20, 2009 at 05:07:34PM -0400, Jeudy, Guillaume wrote:
> Thanks Oleg your replies are very useful. The axis2 issue is known but nobody is addressing it, I might be able to supply a patch for that.
>  
> Regarding point 5. I now use a ResponseHandler passed to httpClient.execute() method. According to docs this will ensure the underlying connection is released no matter the outcome correct?
> 

Yes, this is correct.

 
> I also experienced some issues with CoreProtocolPNames.USE_EXPECT_CONTINUE that is enabled by default. My usecase is the following, i'm accessing a .NET webservice protected by NTLMv2 authentication. When both Transfer-Encoding: chunked and Expect: 100-Continue headers are present in the HttpClient answer the NTLM challenge, the server resets the connection. If I disable chunk mode I still get a HTTP 400 Bad Request (Invalid Verb) error from the server.
> 
> Disabling USE_EXPECT_CONTINUE worked around the problem successfully. Can you please explain why this option is enabled by default? From what I understand that is used to improve performance?
>  

The expect-continue handshake is the only way to get authentication working for entity enclosing requests with non-repeatable entities. This is the reason it is enabled per default.

Hope this helps

Oleg


> Thanks,
> -Guillaume
> 
> ________________________________
> 
> From: Oleg Kalnichevski [mailto:olegk@apache.org]
> Sent: Fri 4/17/2009 8:01 PM
> To: HttpClient User Discussion
> Subject: Re: Porting Axis2 using commons-httpclient 3.1 to httpclient 4.0
> 
> 
> 
> On Fri, 2009-04-17 at 17:17 -0400, Jeudy, Guillaume wrote:
> > Hi,
> 
> Hi
> 
> New API is partially documented in this tutorial:
> 
> http://wiki.apache.org/HttpComponents/HttpClientTutorial
> 
> > 
> > I'm attempting to port axis2 using commons-httpclient 3.1 to httpclient 4.0 locally. I have a few questions because in some instances I could not find corresponding functionality in 4.0 version.
> > 
> > 1)  Is httpMethodBase.setDoAuthentication() still required in 4.0 ?
> >
> 
> No it is not. There is a parameter to disable authentication if not
> desired.
> 
> > My understanding is that such a switch is no longer required, httpclient 4.0 requests will perform authentication by default if credentials are set and authschemes are properly configured on the HttpClient object.
> >
> > 2) What about the Protocol interface implementations? The HostConfiguration class also disappeared. I now use HttpHost to get equivalent functionality in 4.0. I cannot get equivalent functionality for missing Protocol class in defunct HostConfiguration. Can somebody point in the right direction here?
> >  
> 
> See Scheme
> 
> > 3) Preemptive authentication feature. Before it was easy as:
> >
> > httpClient.getParams().setAuthenticationPreemptive(true);   what is easiest way to migrate to 4.0 way of doing it ?
> 
> See examples. There is a couple about preemptive authentication
> 
> http://hc.apache.org/httpcomponents-client/examples.html
> 
> >  
> >  4) Reorder auth scheme priority. before you could do things such as:
> >
> >   List schemes = authenticator.getAuthSchemes();
> > authPrefs.add(AuthPolicy.BASIC);
> > authPrefs.add(AuthPolicy.NTLM);
> > 
> > httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY,
> >      authPrefs);
> >
> > I did not find such customizability in 4.0, any hints? Are all registered auth scheme applied in indefinite order in 4.0?
> >
> 
> Subclass DefaultTargetAuthenticationHandler and override
> #getAuthPreferences() method
> 
> 
> > 5) connection management before you had to do:
> >
> > try {
> >    httpClient.executeMethod(config, method);
> > } finally {
> >      method.releaseConnection();
> > }
> >
> 
> See tutorial and examples. There is enough material about connection
> management already. I'll be adding more in the coming days / months.
> 
> > to ensure the connection bound to the HttpMethodBase object is released. In 4.0 version, are connections always released by default whenever httpClient.executeX() is called no matter the outcome? If not please give more insight on how this works in 4.0.
> > 
> 
> However, before you seriously consider migrating Axis2 to HttpClient 4.0
> you should get Axis folks to take a look at this issue:
> 
> https://issues.apache.org/jira/browse/AXIS2-3933
> 
> I raised that issue almost a year ago. Still no reaction. I have pretty
> much given up on Axis2.
> 
> Cheers
> 
> Oleg
> 
> > Thank you!
> > -Guillaume
> > 
> >
> >
> > ____________________________________________________________________________________________________
> > This electronic mail (including any attachments) may contain information that is privileged, confidential, and/or otherwise protected from disclosure to anyone other than its intended recipient(s). Any dissemination or use of this electronic email or its contents (including any attachments) by persons other than the intended recipient(s) is strictly prohibited. If you have received this message in error, please notify us immediately by reply email so that we may correct our internal records. Please then delete the original message (including any attachments) in its entirety. Thank you.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 
> 
> 
> 
> ____________________________________________________________________________________________________
> This electronic mail (including any attachments) may contain information that is privileged, confidential, and/or otherwise protected from disclosure to anyone other than its intended recipient(s). Any dissemination or use of this electronic email or its contents (including any attachments) by persons other than the intended recipient(s) is strictly prohibited. If you have received this message in error, please notify us immediately by reply email so that we may correct our internal records. Please then delete the original message (including any attachments) in its entirety. Thank you.
> 

> 
> ---------------------------------------------------------------------
> 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: Porting Axis2 using commons-httpclient 3.1 to httpclient 4.0

Posted by "Jeudy, Guillaume" <gj...@teksystems.com>.
Thanks Oleg your replies are very useful. The axis2 issue is known but nobody is addressing it, I might be able to supply a patch for that.
 
Regarding point 5. I now use a ResponseHandler passed to httpClient.execute() method. According to docs this will ensure the underlying connection is released no matter the outcome correct?
 
I also experienced some issues with CoreProtocolPNames.USE_EXPECT_CONTINUE that is enabled by default. My usecase is the following, i'm accessing a .NET webservice protected by NTLMv2 authentication. When both Transfer-Encoding: chunked and Expect: 100-Continue headers are present in the HttpClient answer the NTLM challenge, the server resets the connection. If I disable chunk mode I still get a HTTP 400 Bad Request (Invalid Verb) error from the server.

Disabling USE_EXPECT_CONTINUE worked around the problem successfully. Can you please explain why this option is enabled by default? From what I understand that is used to improve performance?
 
Thanks,
-Guillaume

________________________________

From: Oleg Kalnichevski [mailto:olegk@apache.org]
Sent: Fri 4/17/2009 8:01 PM
To: HttpClient User Discussion
Subject: Re: Porting Axis2 using commons-httpclient 3.1 to httpclient 4.0



On Fri, 2009-04-17 at 17:17 -0400, Jeudy, Guillaume wrote:
> Hi,

Hi

New API is partially documented in this tutorial:

http://wiki.apache.org/HttpComponents/HttpClientTutorial

> 
> I'm attempting to port axis2 using commons-httpclient 3.1 to httpclient 4.0 locally. I have a few questions because in some instances I could not find corresponding functionality in 4.0 version.
> 
> 1)  Is httpMethodBase.setDoAuthentication() still required in 4.0 ?
>

No it is not. There is a parameter to disable authentication if not
desired.

> My understanding is that such a switch is no longer required, httpclient 4.0 requests will perform authentication by default if credentials are set and authschemes are properly configured on the HttpClient object.
>
> 2) What about the Protocol interface implementations? The HostConfiguration class also disappeared. I now use HttpHost to get equivalent functionality in 4.0. I cannot get equivalent functionality for missing Protocol class in defunct HostConfiguration. Can somebody point in the right direction here?
>  

See Scheme

> 3) Preemptive authentication feature. Before it was easy as:
>
> httpClient.getParams().setAuthenticationPreemptive(true);   what is easiest way to migrate to 4.0 way of doing it ?

See examples. There is a couple about preemptive authentication

http://hc.apache.org/httpcomponents-client/examples.html

>  
>  4) Reorder auth scheme priority. before you could do things such as:
>
>   List schemes = authenticator.getAuthSchemes();
> authPrefs.add(AuthPolicy.BASIC);
> authPrefs.add(AuthPolicy.NTLM);
> 
> httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY,
>      authPrefs);
>
> I did not find such customizability in 4.0, any hints? Are all registered auth scheme applied in indefinite order in 4.0?
>

Subclass DefaultTargetAuthenticationHandler and override
#getAuthPreferences() method


> 5) connection management before you had to do:
>
> try {
>    httpClient.executeMethod(config, method);
> } finally {
>      method.releaseConnection();
> }
>

See tutorial and examples. There is enough material about connection
management already. I'll be adding more in the coming days / months.

> to ensure the connection bound to the HttpMethodBase object is released. In 4.0 version, are connections always released by default whenever httpClient.executeX() is called no matter the outcome? If not please give more insight on how this works in 4.0.
> 

However, before you seriously consider migrating Axis2 to HttpClient 4.0
you should get Axis folks to take a look at this issue:

https://issues.apache.org/jira/browse/AXIS2-3933

I raised that issue almost a year ago. Still no reaction. I have pretty
much given up on Axis2.

Cheers

Oleg

> Thank you!
> -Guillaume
> 
>
>
> ____________________________________________________________________________________________________
> This electronic mail (including any attachments) may contain information that is privileged, confidential, and/or otherwise protected from disclosure to anyone other than its intended recipient(s). Any dissemination or use of this electronic email or its contents (including any attachments) by persons other than the intended recipient(s) is strictly prohibited. If you have received this message in error, please notify us immediately by reply email so that we may correct our internal records. Please then delete the original message (including any attachments) in its entirety. Thank you.


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






____________________________________________________________________________________________________
This electronic mail (including any attachments) may contain information that is privileged, confidential, and/or otherwise protected from disclosure to anyone other than its intended recipient(s). Any dissemination or use of this electronic email or its contents (including any attachments) by persons other than the intended recipient(s) is strictly prohibited. If you have received this message in error, please notify us immediately by reply email so that we may correct our internal records. Please then delete the original message (including any attachments) in its entirety. Thank you.


Re: Porting Axis2 using commons-httpclient 3.1 to httpclient 4.0

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2009-04-17 at 17:17 -0400, Jeudy, Guillaume wrote:
> Hi,

Hi 

New API is partially documented in this tutorial:

http://wiki.apache.org/HttpComponents/HttpClientTutorial

>  
> I'm attempting to port axis2 using commons-httpclient 3.1 to httpclient 4.0 locally. I have a few questions because in some instances I could not find corresponding functionality in 4.0 version.
>  
> 1)  Is httpMethodBase.setDoAuthentication() still required in 4.0 ?
> 

No it is not. There is a parameter to disable authentication if not
desired.

> My understanding is that such a switch is no longer required, httpclient 4.0 requests will perform authentication by default if credentials are set and authschemes are properly configured on the HttpClient object.
> 
> 2) What about the Protocol interface implementations? The HostConfiguration class also disappeared. I now use HttpHost to get equivalent functionality in 4.0. I cannot get equivalent functionality for missing Protocol class in defunct HostConfiguration. Can somebody point in the right direction here?
>   

See Scheme

> 3) Preemptive authentication feature. Before it was easy as:
> 
> httpClient.getParams().setAuthenticationPreemptive(true);   what is easiest way to migrate to 4.0 way of doing it ?

See examples. There is a couple about preemptive authentication

http://hc.apache.org/httpcomponents-client/examples.html

>   
>  4) Reorder auth scheme priority. before you could do things such as:
> 
>   List schemes = authenticator.getAuthSchemes();
> authPrefs.add(AuthPolicy.BASIC);
> authPrefs.add(AuthPolicy.NTLM);
>  
> httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY,
>      authPrefs);
> 
> I did not find such customizability in 4.0, any hints? Are all registered auth scheme applied in indefinite order in 4.0?
> 

Subclass DefaultTargetAuthenticationHandler and override
#getAuthPreferences() method


> 5) connection management before you had to do:
> 
> try {
>    httpClient.executeMethod(config, method);
> } finally {
>      method.releaseConnection();
> }
> 

See tutorial and examples. There is enough material about connection
management already. I'll be adding more in the coming days / months.

> to ensure the connection bound to the HttpMethodBase object is released. In 4.0 version, are connections always released by default whenever httpClient.executeX() is called no matter the outcome? If not please give more insight on how this works in 4.0.
>  

However, before you seriously consider migrating Axis2 to HttpClient 4.0
you should get Axis folks to take a look at this issue:

https://issues.apache.org/jira/browse/AXIS2-3933

I raised that issue almost a year ago. Still no reaction. I have pretty
much given up on Axis2.

Cheers

Oleg

> Thank you!
> -Guillaume
>  
> 
> 
> ____________________________________________________________________________________________________
> This electronic mail (including any attachments) may contain information that is privileged, confidential, and/or otherwise protected from disclosure to anyone other than its intended recipient(s). Any dissemination or use of this electronic email or its contents (including any attachments) by persons other than the intended recipient(s) is strictly prohibited. If you have received this message in error, please notify us immediately by reply email so that we may correct our internal records. Please then delete the original message (including any attachments) in its entirety. Thank you.


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