views:

134

answers:

1

I am using org.apache.http.impl.client.DefaultHttpClient to retrieve xml from a webservice and am trying to determine whether to set

HttpProtocolParams.setUseExpectContinue(params, true) 

or

HttpProtocolParams.setUseExpectContinue(params, false)

I am not clear on how to determine this. Can anyone offer a best practices guideline on when this should be true and when it should be false and also the possible implications of each setting?

+1  A: 

It should be false in most cases.

Expect-Continue is only needed when your request is large (like file uploading) and the server may have authorization requirement. You don't want send a huge file and get a Access Denied error. So you just send the headers first and if the server says continue, you will then send the whole request.

We had some performance problem with a Curl-based system and we found out 100-Continue is causing the request being send twice. It turns out Curl has 100-Continue turned on by default.

ZZ Coder
Thanks a lot for that excellent answer. I appreciate it.