Hello everyone, I have a system that uses indy to make https connections,
but I have a huge problem since I need to have it in a thread and update a
TStringList with the data in the main form, which causes several problems
because it locks the UI when The connection is slow. I tried to do the same
with the "TSslHTTPCli" component, I get the login data for the login page
using "POST" and "PostASync", but when doing a GET on the next page that
should be accessed with the logged in user, it is as if I have not logged
in, I do not know if I am storing the session as it should, after logging
in I need to use the session to access several other pages, including new
instances of "TSslHTTPCli" creating at runtime, Obs: I used "post" only For
testing, more accurate "PostASync" and "GetASync" to not crash the UI.
Could you help me with this, please? Follow my code below:

======================================

var
    DataOut : TMemoryStream;
    DataIn  : TFileStream;
    Buf     : AnsiString;
    I       : Integer;
begin
    DisplayMemo.Clear;

    try
        DataOut := TMemoryStream.Create;
        Buf     :=
AnsiString('param=1&Login=userlogin&Senha=userpass&xx2a=1');
        if Length(Buf) > 0 then      { Check if some data to post }
            DataOut.Write(Buf[1], Length(Buf));
        DataOut.Seek(0, soBeginning);

        HttpCli1.SendStream      := DataOut;
        HttpCli1.Proxy           := '';
        HttpCli1.ProxyPort       := '';
        HttpCli1.Connection      := 'Keep-Alive';
        HttpCli1.RcvdStream      := nil;
        HttpCli1.ContentTypePost := '';
        HttpCli1.URL             := 'https://www.homepage.br/loginpage.asp';
        HttpCli1.RequestVer      := '1.0';

        HttpCli1.Options := HttpCli1.Options + [httpoEnableContentCoding];
        HttpCli1.Cookie := IcsCookies.GetCookies(HttpCli1.URL);  // 7.02
send cookies

        try
            //HttpCli1.PostASync;

            HttpCli1.Post;

            HttpCli1.URL := 'https://www.homepage.gov.br/intro.htm';
            HttpCli1.Get;

            HttpCli1.URL := 'https://www.homepage.gov.br/t_top.asp';
            HttpCli1.Get;

            HttpCli1.URL := 'https://www.homepage.gov.br/main2.asp';
            HttpCli1.Get;

            HttpCli1.URL := '/www.homepage.gov.br/pag.asp';
            HttpCli1.GetASync

        except
            DataOut.Free;
            Display('Request Failed !');
            Display('StatusCode   = ' + IntToStr(HttpCli1.StatusCode));
            Display('ReasonPhrase = ' + HttpCli1.ReasonPhrase);
            Exit;
        end;
        DataOut.Free;

    finally
    end;
end;


I am based on the example in "C:\Program Files
(x86)\Embarcadero\Studio\18.0\lib\ics\Samples\Delphi\SslInternet" put the
same events

Follows part of the logs when accessing the private page.

---------------------------------------------------

Document = main2.asp
! 567 bytes document received/sent in 0 milliseconds
Request done, StatusCode #200
hdr>HTTP/1.1 200 OK
hdr>Cache-Control: private
hdr>Content-Length: 567
hdr>Content-Type: text/html
hdr>Expires: Thu, 25 May 2017 16:53:45 GMT
hdr>Server: Microsoft-IIS/8.5
hdr>Set-Cookie: ASPSESSIONIDCEBSQRTD=ADLEIAEDEHFIHNLLLOGBJOAM; secure;
path=/
hdr>X-Powered-By: ASP.NET
hdr>Date: Thu, 25 May 2017 16:53:44 GMT
hdr>Connection: keep-alive
cmd> GET /pags/private.asp HTTP/1.0
cmd> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
cmd> Connection: Keep-Alive
cmd> User-Agent: Mozilla/4.0 (compatible; ICS; MSIE 4.0)
cmd> Host: www.homepag.br
cmd> Proxy-Connection: Keep-Alive
cmd>
HTTP/1.1 302 Object moved
Cache-Control: private
Content-Length: 138
Content-Type: text/html
Location: /accessDenied.htm
Server: Microsoft-IIS/8.5
Cookie: "ASPSESSIONIDCEBSQRTD=BDLEIAEDMMALIONAPKJHONHM; secure; path=/"
Set-Cookie: ASPSESSIONIDCEBSQRTD=BDLEIAEDMMALIONAPKJHONHM; secure; path=/
X-Powered-By: ASP.NET
Date: Thu, 25 May 2017 16:53:44 GMT
Connection: keep-alive
text/html => private.asp
Document = private.asp
! 138 bytes document received/sent in 15 milliseconds
hdr>HTTP/1.1 302 Object moved
hdr>Cache-Control: private
hdr>Content-Length: 138
hdr>Content-Type: text/html
hdr>Location: /accessDenied.htm
hdr>Server: Microsoft-IIS/8.5
hdr>Set-Cookie: ASPSESSIONIDCEBSQRTD=BDLEIAEDMMALIONAPKJHONHM; secure;
path=/




Some data and urls have been changed to keep my privacy, thank you in
advance!
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to