Re: Cannot post data

Giganews Newsgroups
Subject: Re: Cannot post data
Posted by:  Remy Lebeau (TeamB) (no.spam@no.spam.com)
Date: Mon, 15 Aug 2005

<fer> wrote in message news:F16E8D876FD6E240fer...

> Content-Type: application/x-www-form-urlencoded
<snip>
>  PStream := TIdMultiPartFormDataStream.Create ;
<snip>

TIdMultiPartFormDataStream is NOT the way to send
"application/x-www-form-urlencoded" requests.  TIdMultiPartFormDataStream is
specifically designed to only handle "multipart/form-data" requests instead.
To do what you are asking for, you need to use a TStringList instead of a
TIdMultiPartFormDataStream.

> MyHttp.ProtocolVersion        := pv1_1 ;

You need to also add the hoKeepOrigProtocol flag to the Options property, or
else Post() will automatically change the ProtocolVersion to pv1_0.

>  PUrl := 'https://sube.garanti.com.tr/isube/login HTTP/1.1' ;

That is not correct.  Get rid of the protocol version, it does not belong in
the URL.  TIdHTTP automatically submits the protocol version internally.
You never need to specify it manually.

With all of that said, use this code instead:

    MyHttp := TIdHTTP.Create ;
    try
        MyHttp.IOHandler := Form1.IdSSLIOHandlerSocketOpenSSL1;
        MyHttp.CookieManager := Form1.IdCookieManager1;
        MyHttp.AllowCookies := True;
        MyHttp.ProtocolVersion := pv1_1;
        MyHttp.Options := MyHttp.Options + hoKeepOrigProtocol;
        MyHttp.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg,
image/pjpeg, application/vnd.ms-excel,application/vnd.ms-powerpoint,
application/msword, application/x-shockwave-flash, */*';
        MyHttp.Request.AcceptEncoding := 'gzip, deflate';
        MyHttp.Request.AcceptLanguage := 'tr';
        MyHttp.Request.Connection := 'Keep-Alive';
        MyHttp.Request.ContentType := 'application/x-www-form-urlencoded';
        MyHttp.Request.Referer :=
'https://sube.garanti.com.tr/isube/loginform';
        MyHttp.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.1; SV1; .NET CLR 1.1.4322)';

        PList := TStringList.Create ;
        try
            PList.Add('sid=1') ;
            PList.Add('textMARS=myuserid') ;
            PList.Add('PAROLA=mypass')  ;
            PList.Add('textUSERCUSTNO=')  ;
            PList.Add('hiddenCHOICE=1') ;
            PList.Add('LANG=TR') ;
            PList.Add('KANAL=G') ;
            PList.Add('count=1') ;
            PList.Add('hiddenPASSFIELD=H') ;
            PList.Add('hiddenTOKEN=') ;
            PList.Add('hiddenJVERSION=') ;
            PList.Add('girisButton.x=0') ;
            PList.Add('girisButton.y=0') ;

            Form1.Memo1.Text :=
MyHttp.Post('https://sube.garanti.com.tr/isube/login', PList) ;
        finally
            PList.Free;
        end;
    finally
        MyHttp.Free;
    end;

Gambit

Replies

None

In response to

Cannot post data posted by fer on Mon, 15 Aug 2005