[fpc-pascal] TFPHTTPClient Post works with jetty, fails with tomcat

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Feb 9 00:58:57 CET 2012


On Tue, 7 Feb 2012 10:33:04 +0100
Rainer Stratmann <RainerStratmann at t-online.de> wrote:

> Am Monday 19 December 2011 01:22:18 schrieb Mattias Gaertner:
> > Hi,
> >
> > For some reason TFPHTTPClient.Post hangs when accessing a "solr"
> > server over "tomcat". It works with "solr" over "jetty".
> > "curl" works fine with both, so I guess the tomcat server works
> > normally.
> >
> > Here is the code:
> >
> >     client:=TFPHTTPClient.Create(nil);
> >     client.RequestHeaders.Add('Content-Type: text/xml');
> >     client.RequestBody:=ms; // a TMemoStream with some xml to post
> >     client.Post(URL);
> >
> > It hangs here:
> >
> > procedure TFPCustomHTTPClient.ReadResponse
> > ...
> >   else if L<0 then
> >     // No content-length, so we read till no more data available.
> >     Repeat
> >       R:=Transfer(ReadBufLen);
> >     until (R=0);
> 
> If you have no content-length then mostly in the header ist a 
> field 'Transfer-Encoding: chunked'. Then the content is send in snippets. It 
> is exactly defined how long to read until there is no more content.
> 
> http://en.wikipedia.org/wiki/Chunked_transfer_encoding

Thanks for the hint. I implemented chunked reading and now it works
fast without timeouts. :)

Mattias

trick.



More information about the fpc-pascal mailing list