Forum > Networking and Web Programming

TFPHTTPClient holds the last cookie only

(1/3) > >>

engkin:
I believe this is a bug in TFPCustomHTTPClient. I tracked it down to ReadResponseHeaders:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TFPCustomHTTPClient.ReadResponseHeaders: integer;   Procedure DoCookies(S : String);   Var    P : Integer;    C : String;   begin    If Assigned(FCookies) then    ///  <--------  Bug      FCookies.Clear;             ///  <-------- /    P:=Pos(':',S);    System.Delete(S,1,P);    Repeat      P:=Pos(';',S);      If (P=0) then        P:=Length(S)+1;      C:=Trim(Copy(S,1,P-1));      Cookies.Add(C);      System.Delete(S,1,P);    Until (S='') or Terminated;  end; Const  SetCookie = 'set-cookie'; Var  StatusLine,S : String; begin  if not ReadString(StatusLine) then    Exit(0);  Result:=ParseStatusLine(StatusLine);  Repeat    if ReadString(S) and (S<>'') then      begin      ResponseHeaders.Add(S);      If (LowerCase(Copy(S,1,Length(SetCookie)))=SetCookie) then        DoCookies(S);      end  Until (S='') or Terminated;  If Assigned(FOnHeaders) and not Terminated then    FOnHeaders(Self);end;It clears FCookies repeatedly instead of accumulating all received cookies.

torumyax:
I haven't tested TFPHTTPClient yet, but is there an official github repository for the TFP** libraries? That would be nice...'cause I'm struggling with TFPHttpServer right now...

engkin:
There is no official github repo. There is an official svn or web

torumyax:
Thank you for the sharing!

Thaddy:
As long as session cookies are meant, the behavior looks correct to me. If not it is indeed a bug. (But I am a cookie hater: best (intention) and worst (mis-use) idea ever invented. Servers should maintain state, not clients)

Navigation

[0] Message Index

[#] Next page

Go to full version