[fpc-pascal] Using fphttpclient to simulate web action sequence

Michael Van Canneyt michael at freepascal.org
Thu Apr 30 09:13:23 CEST 2015

On Wed, 29 Apr 2015, leledumbo wrote:

>> If the problem disappears after you do a Free and Create of the http class,
> then it means something is left hanging after the call.
> If I Free and re-Create the class, how can I ensure the request header of
> subsequent requests contain the same cookies? I need to maintain 2 cookie
> values (which is given from first GET request in the response header)
> throughout all requests.

Just extract the and save the value of the Set-Cookie header ?
I always store the cookies explicitly.

The class doesn't automatically handle cookies. 
It doesn't store and retrieve the cookies. 
Specifically, if it gets a set-cookie, it will not apply it to the next request.

We can think of a "TCookieJar" class implementation as an option, but for now
you must handle cookies yourself.

> Each request log is delimited by BEGIN-END line. As you can see, in the
> first request, the response indicates 2 Set-Cookie:, which must be preserved
> for subsequent requests. But in the next request, the request header
> contains no Cookie: line, which is why the server issues another
> Set-Cookie:, though this time it's only sirclo_session_id issued, the
> cart_code is not issued again. Still, this is wrong as both must appear
> instead of just one of them.
> P.S.:
> 1. I guess RequestHeaders.Text doesn't contain Cookie: line, does it?

It must

> 2. 302 response status code is expected, should not be a problem

I have plans to handle this in TFPHTTPClient.


More information about the fpc-pascal mailing list