Board index » delphi » HTTPS Post....

HTTPS Post....


2004-04-26 11:25:36 PM
delphi78
I am feeling stupid, but...I bought and read Indy in Depth, have checked
here, etc. etc.
This should be easy.
I want to use Indy to do the functional equivalent of this submit:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<script type = "text/javascript">
function senditnow(){ document.myform.onsubmit();
document.myform.submit(); }
</script>
<body onload = 'senditnow();'>
<form name="myform" id="myform"
action="https://pmi-acpt.eyefinity.com/servlet/PMIServlet" method="post"
onsubmit="message.value
='==|PMIVer=1.1|FMVer=1.0|Vsv=8.0|Vid=compulink|Vpw=cA913Ck|Rid=9168514838|Rpw=9168|Oid=00000123433361|Rt=BDS-VAL-MBR|Mid=370126101|Oph=9168514838|Mnm=EDISON,THOMAS|Gid=1202280100020001|Gnm=HONDA
OF AMERICA|Pnm=EDISON,
THOMAS|Pbd=19040101|Prd=?|Gdti=?|Mnm=?|Eld=?|Eid=?|Fid=?|Fnm=?||From=compulink';
return true;">
<INPUT type="hidden" name="message" rows="8" cols="58">
<INPUT type="submit" name="submit_message" value="Submit Request">
</form>
</body>
</html>
I have tried different permutations of:
procedure TForm1.Button1Click(Sender: TObject);
var MyData: String;
var SendData: TStrings;
begin
SendData := TStringList.Create;
// VSPHttp.Host := 'https://pmi-acpt.eyefinity.com/servlet/PMIServlet';
VSPHttp.Host := 'https://pmi-acpt.eyefinity.com';
MyData :=
'==|PMIVer=1.1|FMVer=1.0|Vsv=8.0|Vid=compulink|Vpw=cA913Ck|Rid=9168514838|Rpw=9168|Oid=00000123433361|Rt=BDS-VAL-MBR|Mid=370126101|Oph=9168514838';
MyData := MyData+ '|Mnm=EDISON,THOMAS|Gid=1202280100020001|Gnm=HONDA OF
AMERICA|Pnm=EDISON,
THOMAS|Pbd=19040101|Prd=?|Gdti=?|Mnm=?|Eld=?|Eid=?|Fid=?|Fnm=?|';
SendData.Add(MyData);
VSPHttp.Connect(1000);
try
VSPHttp.Post('https://pmi-acpt.eyefinity.com/servlet/PMIServlet',
SendData);
finally
VSPHttp.Disconnect;
end;
MyData := VSPHttp.ResponseText;
ShowMessage(MyData);
end;
VSPHttp is a TIdHTTP, I have tried it with and without IOSSL
Currently I get an EIDSocketError Socket Error 11004.
Without the .Connect my app accesses the internet, then finally returns a
error Connection refused, or, more commonly EIDHTTPProtocolException
"HTTP/1.1 400 Bad Request"
Option 2:
procedure TForm1.Button2Click(Sender: TObject);
var
stream,backstream: TIdMultiPartFormDataStream;
MyData: String;
begin
stream := TIdMultiPartFormDataStream.Create;
VSPHttp.Connect(1000);
try
MyData :=
'==|PMIVer=1.1|FMVer=1.0|Vsv=8.0|Vid=compulink|Vpw=cA913Ck|Rid=9168514838|Rpw=9168|Oid=00000123433361|Rt=BDS-VAL-MBR|Mid=370126101|Oph=9168514838';
MyData := MyData+ '|Mnm=EDISON,THOMAS|Gid=1202280100020001|Gnm=HONDA OF
AMERICA|Pnm=EDISON,
THOMAS|Pbd=19040101|Prd=?|Gdti=?|Mnm=?|Eld=?|Eid=?|Fid=?|Fnm=?|';
stream.AddFormField('message',MyData);
//
VSPHTTP.DoRequest(hmPost,'https://pmi-acpt.eyefinity.com/servlet/PMIServlet',
// stream,backstream);
VSPhttp.Post('https://pmi-acpt.eyefinity.com/servlet/PMIServlet',
stream);
finally
stream.Free;
VSPHttp.Disconnect;
end;
end;
This connects, but then times out.
Any help would be appreciated. I think I am just being stupid about this.
Doug
 
 

Re:HTTPS Post....

"Doug Johnson" <XXXX@XXXXX.COM>writes
Quote
I want to use Indy to do the functional equivalent of this submit:
var
Values: TStringList;
MyData: String;
begin
Values := TStringList.Create;
try
Values['message'] :=
'==|PMIVer=1.1|FMVer=1.0|Vsv=8.0|Vid=compulink|Vpw=cA913Ck|Rid=9168514838|Rp
w=9168|Oid=00000123433361|Rt=BDS-VAL-MBR|Mid=370126101|Oph=9168514838|Mnm=ED
ISON,THOMAS|Gid=1202280100020001|Gnm=HONDA
OF AMERICA|Pnm=EDISON,
THOMAS|Pbd=19040101|Prd=?|Gdti=?|Mnm=?|Eld=?|Eid=?|Fid=?|Fnm=?||From=compuli
nk';
MyData :=
IdHTTP1.Post('https://pmi-acpt.eyefinity.com/servlet/PMIServlet', Values);
finally
Values.Free
end;
end;
Gambit
 

Re:HTTPS Post....

Thanks for the response. I got an error on trying to compile, since
Values['message'] was expecting an integer, not a string.
By chance would this be what you meant to send me?
Values: TStringList;
MyData: String;
begin
MyData :=
'==|PMIVer=1.1|FMVer=1.0|Vsv=8.0|Vid=compulink|Vpw=cA913Ck|Rid=9168514838|Rpw=9168|Oid=00000123433361|Rt=BDS-VAL-MBR|Mid=370126101|Oph=9168514838';
MyData := MyData+ '|Mnm=EDISON,THOMAS|Gid=1202280100020001|Gnm=HONDA OF
AMERICA|Pnm=EDISON,
THOMAS|Pbd=19040101|Prd=?|Gdti=?|Mnm=?|Eld=?|Eid=?|Fid=?|Fnm=?|';
Values := TStringList.Create;
try
Values.Add('message='+MyData);
VSpHTTP.Post('https://pmi-acpt.eyefinity.com/servlet/PMIServlet',
Values);
finally
Values.Free
end;
If not, what needs to be in the TStringList for it to post like the
previous code?
If it is correct, then I am still getting an exception
EIDHTTPProtocolException "HTTP/1.1 400 Bad Request"
I notice that it mentions HTTP 1.1 and the documentation says that Post
always downsteps to HTTP 1.0.
I did attach the IDSSLIOHandler to TidHTTP.
Again, thanks for the help.
Doug
On Mon, 26 Apr 2004 12:04:14 -0700, Remy Lebeau (TeamB)
<XXXX@XXXXX.COM>writes:
Quote

"Doug Johnson" <XXXX@XXXXX.COM>writes
news:opr62k4yzql2v16a@localhost...

>I want to use Indy to do the functional equivalent of this submit:

var
Values: TStringList;
MyData: String;
begin
Values := TStringList.Create;
try
Values['message'] :=
'==|PMIVer=1.1|FMVer=1.0|Vsv=8.0|Vid=compulink|Vpw=cA913Ck|Rid=9168514838|Rp
w=9168|Oid=00000123433361|Rt=BDS-VAL-MBR|Mid=370126101|Oph=9168514838|Mnm=ED
ISON,THOMAS|Gid=1202280100020001|Gnm=HONDA
OF AMERICA|Pnm=EDISON,
THOMAS|Pbd=19040101|Prd=?|Gdti=?|Mnm=?|Eld=?|Eid=?|Fid=?|Fnm=?||From=compuli
nk';

MyData :=
IdHTTP1.Post('https://pmi-acpt.eyefinity.com/servlet/PMIServlet',
Values);
finally
Values.Free
end;
end;


Gambit


 

Re:HTTPS Post....

As an alternative, is there a way to capture a conversation between
Internet Explorer and a server as I run the working script, then duplicate
that conversation with the changes that I need...effectively to eavesdrop
in on my own conversation with the server (I have no control over the
server and pretty sparse documentation on their expectations, even though
I am supposed to write the interface).
Doug
 

Re:HTTPS Post....

"Doug Johnson" <XXXX@XXXXX.COM>writes
Quote
I got an error on trying to compile, since Values['message']
was expecting an integer, not a string.
Change this line:
Values['message'] := '...';
To this instead:
Values.Values['message'] := '...';
Gambit
 

Re:HTTPS Post....

"Doug Johnson" <XXXX@XXXXX.COM>writes
Quote
As an alternative, is there a way to capture a conversation
between Internet Explorer and a server as I run the working
script, then duplicate that conversation with the changes that I need...
Use a packet sniffer, such as Ethereal, www.ethereal.com
Gambit
 

Re:HTTPS Post....

Thanks. It compiles now. It still gets a protocol exception, but with
the packet sniffer I should be able to see the differences. Does Indy URL
encode the text? If not, that could be my problem. In Delphi 5, there
was the FastNet TNMURL for encoding, but I am finding nothing in 7.
Is there something comparable, or do I need to install another component?
Doug
On Mon, 26 Apr 2004 14:32:52 -0700, Remy Lebeau (TeamB)
<XXXX@XXXXX.COM>writes:
Quote

"Doug Johnson" <XXXX@XXXXX.COM>writes
news:opr62xltz5l2v16a@localhost...

>I got an error on trying to compile, since Values['message']
>was expecting an integer, not a string.

Change this line:

Values['message'] := '...';

To this instead:

Values.Values['message'] := '...';


Gambit


 

Re:HTTPS Post....

"Doug Johnson" <XXXX@XXXXX.COM>writes
Quote
Does Indy URL encode the text?
Yes, it does encode the post data, but only if hoForceEncodeParams is
enabled in the Options property.
Quote
In Delphi 5, there was the FastNet TNMURL for encoding,
but I am finding nothing in 7. Is there something comparable,
or do I need to install another component?
Indy has a TIdURI class that can do that.
Gambit
 

Re:HTTPS Post....

Thank you for all your help....
I got it working thanks to your input. Bless you.
Doug