[fpc-pascal] Cannot reuse TFPHTTPClient object for 2 different POST requests

leledumbo leledumbo_cool at yahoo.co.id
Mon Jan 19 06:43:06 CET 2015

> Yes, I can. The TFPHTTPClient instance is not stateless. 
> Before doing a call, some headers are added to the request headers if they
> are not there yet. 
> For example, the Content-Size header. 
> But the Content-Size header is not added if is already present. 
> For calls 1 and 2 it does not matter, since the size is the same. 
> For the third call, however, it does matter, since the content-size header
> still contains the size of call 2 (93), 
> which does not match the size of call 3: call 3 has less data (57). 
> So the server is waiting for more data (it expects 93 bytes as indicated
> in Content-Size instead of 57 actually present). 
> The solution is simple: Try clearing the headers before doing your calls. 
>    WriteLn('Response 2:'); 
>    HTTP.RequestHeaders.Clear; 
> etc. then it will work. (it does here) 

This is the answer I need, thanks :)

Looks like this needs some kind of documentation or at least comment
somewhere in the source.

I still wonder why the header is not updated based on given parameters

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Cannot-reuse-TFPHTTPClient-object-for-2-different-POST-requests-tp5720779p5720793.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.

More information about the fpc-pascal mailing list