On Fri, 2008-06-06 at 15:06 +0200, Martin Zdila wrote:
> Hi Ortwin
>
> On Fri 6. June 2008 14:11:47 Ortwin Glück wrote:
> > DEBUG [main] org.apache.http.wire - >> "POST /post.html HTTP/1.1[EOL]"
> > DEBUG [main] org.apache.http.wire - >> "Content-Length: 0[EOL]"
> > DEBUG [main] org.apache.http.wire - >> "Host: www.zdila.sk[EOL]"
> > DEBUG [main] org.apache.http.wire - >> "Connection: Keep-Alive[EOL]"
> > DEBUG [main] org.apache.http.wire - >> "[EOL]"
> >
> > This first request is without entity body (0 length). Weird, but legal.
>
> The first method should have been HttpGet, but it doesn't matter as even
> HttPost with no entity is legal, as you mentioned. Fixing that and re-running
> testcase doesn't solve the issue.
>
> >
> > DEBUG [main] org.apache.http.wire - >> "POST /post.html HTTP/1.1[EOL]"
> > DEBUG [main] org.apache.http.wire - >> "Content-Length: 13[EOL]"
> > DEBUG [main] org.apache.http.wire - >> "Host: www.zdila.sk[EOL]"
> > DEBUG [main] org.apache.http.wire - >> "Connection: Keep-Alive[EOL]"
> > DEBUG [main] org.apache.http.wire - >> "[EOL]"
> >
> >
> > This POST request specifies 13 bytes content length but does not seem to
> > send the entity body. Why, I don't now.
> >
> >
> > Now the code that produces that is:
> >
> > postMethod.setEntity(new InputStreamEntity(new
> > ByteArrayInputStream("submit=submit".getBytes()), 13));
How many times can one read to the end an input stream? Only once.
Therefore request entities backed by an InputStream instance cannot be
retried. This is precisely the reason why the target server is not
sending any data back, because it is waiting for those 13 bytes of
content.
I'll patch HttpClient to throw an exception if an attempt is made to
retry a request with a non-repeatable request entity.
Meanwhile I suggest you change you code to use a repeatable entity, such
as StringEntity or ByteArrayEntity.
Hope this helps
Oleg
> >
> > Why are you using an InputStreamEntity and not a StringEntity? This code is
> > dependent on your default platform encoding, thus not portable. The size
> > may not be correct. In any case the content type of the request will be
> > wrong.
>
> You are right this code is dependent on default charset platform. It wouldn't
> work for UTF-16. I fixed that to:
>
> postMethod.setEntity(new InputStreamEntity(new
> ByteArrayInputStream("submit=submit".getBytes("US-ASCII")), 13));
>
> Still no success. In any case this line is only for testcase purposes. In my
> application I am actually doing:
>
> postMethod.setEntity(new InputStreamEntity(request.getInputStream(),
> request.getContentLength()));
>
> where request is untouch HttpServletRequest. But it doesn't matter :-).
>
> BTW if i replace both methods to HttpGet, I still get that I/O Error also
> with
> retrying, but program doesn't get locked.
>
> Thanks in advance
> Best regards
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]