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

leledumbo leledumbo_cool at yahoo.co.id
Wed Apr 29 18:45:11 CEST 2015


> 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.

This is a sample output of the program:
BEGIN **********************************************************
[Request Headers]

[Response Status Code]
200
[Response Headers]
Server: nginx
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Vary: Accept-Encoding
Set-Cookie: sirclo_session_id=71e58d13b4124c71a54c0eb6438b8007; path=/
Set-Cookie: cart_code=f654373c175ac6e86da22c7400a146f0; expires=Fri,
29-Apr-2016 16:40:05 GMT; path=/
Pragma: no-cache
Date: Wed, 29 Apr 2015 16:40:05 GMT
X-Page-Speed: ngx_pagespeed 1.8
Cache-Control: max-age=0, no-cache, no-store
Connection: Keep-alive
Via: 1.1 ID-0002262071501332 uproxy-3

END **********************************************************
BEGIN **********************************************************
[Request Headers]
Content-Type: application/x-www-form-urlencoded
Content-Length: 79

[Response Status Code]
302
[Response Headers]
Server: nginx
Date: Wed, 29 Apr 2015 16:40:07 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Set-Cookie: sirclo_session_id=0c9f312bc97c0332105c2accc0feede5; path=/
Location: http://lelelagi.mysirclo.com/cart
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: 0
Connection: Keep-alive
Via: 1.1 ID-0002262071501332 uproxy-6

END **********************************************************
An unhandled exception occurred at $000000000046DCFB:
EHTTPClient: Error reading data from socket
  $000000000046DCFB
  $000000000046DA9B
  $000000000046F344
  $000000000046FAA8
  $000000000047027E

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?
2. 302 response status code is expected, should not be a problem



--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Using-fphttpclient-to-simulate-web-action-sequence-tp5721642p5721644.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.


More information about the fpc-pascal mailing list