Hi all,

 

I  have a scenario where I test error handling when streaming data to a
http server that is not reachable (e.g. the server process is down).

 

With the following settings

client.getParams().setParameter(HttpConnectionParams.STALE_CONNECTION_CH
ECK, true);

 

InputStreamEntity entity = new InputStreamEntity(in, -1);

entity.setChunked(true);

putMethod = new HttpPut(effectiveUri);

putMethod.setEntity(entity);

putMethod.getParams().setParameter(CoreProtocolPNames.USE_EXPECT_CONTINU
E, true);

putMethod.getParams().setParameter(CoreProtocolPNames.WAIT_FOR_CONTINUE,
5000);

 

I get a "org.apache.http.conn.HttpHostConnectException: Connection to
serverXXX refused" before writing anything to the InputStream. This is
just as expected.

 

 

If I disable the stale connection check I don't get this exception.
Instead it seems that either the HttpClient waits for a 100-continue
response (and does not consider the set timeout of 5000 ms because the
execute request blocks) or because of a bug http client thinks expect
100-continue was successful and waits for data to be written

As soon as I write on the InputStream I do get a
"java.net.SocketException: Broken pipe", but I would like to have an
exception before data is written, because the expect 100-continue
request fails because no server is responding.

 

Is this a bug or do I have to add some additional code to get the same
result as when setting stale connection check to TRUE?

 

Bye,

Daniel

Reply via email to