HTTPS高分问题!高手狂入!

borgvardt 2006-06-30 03:19:45
小弟最近开发一个项目,需要向一个服务器发起HTTPS请求,上传用户名和密码,然后由服务器告知是否登陆成功,也就是说要读取返回的内容。
换句话说,小弟想知道如何用DELPHI发起HTTPS请求,上传数据,然后读取Response。
我也查询了一些资料,很多高手说是用TIDHttp+TIdSSLIOHandlerSocket完成,但小弟实在不知如何实现,望各位高手给出简洁的代码,小弟先谢了,分数不够可以加!
...全文
701 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
天涯倦客 2006-11-15
  • 打赏
  • 举报
回复
mark
JLBOY 2006-11-15
  • 打赏
  • 举报
回复
^-^
JLBOY 2006-11-15
  • 打赏
  • 举报
回复
兄弟:用 COOKIE 知道不
不知道網上找
找不到我把代碼給你
原理:
cookie 記憶登入的用戶,然后根據用戶到數據庫里面找到密碼是否正確
hongqi162 2006-11-14
  • 打赏
  • 举报
回复
在服务器创建一个处理用户数据页面用来接收用户信息,

uses Comobj


var
responseText: WideString;
xmlHttp: OLEVariant;
url:string;
begin

url:='http://192.168.1.10/data.aspx?userid=212121&pwd=2121212121';//pwd需要加密
try
xmlHttp:=CreateOleObject('Msxml2.XMLHTTP');
xmlHttp.open('GET',url,false);
xmlHttp.send();
responseText:=xmlHttp.responseText;
if xmlHttp.status='200' then
begin
Result:=responseText;
//处理responseText。。。。。。。。。。。。。。。。。。。。。。
end;
xmlHttp := Unassigned;
except
end;
rongjch 2006-11-14
  • 打赏
  • 举报
回复
还是不太懂...
dabaicai 2006-07-03
  • 打赏
  • 举报
回复
我用idhttp get用户名和密码,通过返回的信息判断是否登录成功
ly_liuyang 2006-07-03
  • 打赏
  • 举报
回复
用Indy也是可以的,呵呵
huitouren519 2006-07-03
  • 打赏
  • 举报
回复
mark
学习
mengjj 2006-06-30
  • 打赏
  • 举报
回复
找到了,这是个发送test.xml文件到https服务器的测试程序:
此程序用到了两个Type library

在delphi中选择菜单Project->Import Type library,然后分别把
Microsoft WinHTTP Services,version5.1(Version 5.1)

Microsoft Scripting Runtime (Version 1.0)
加到程序中 (点击Create Unit)



代码:
procedure TForm1.Button1Click(Sender: TObject);
var
http:WinhttpRequest;
fso:FileSystemObject;
fs:TextStream;
fil:File_;
url,user,password,path,xmlFile,statusStr:string;
begin
try
path:='c:\test.xml';
url:='https://test/test/test';
user:='test';
password:='test';

fso:=CreateComObject(CLASS_FileSystemObject) as FileSystemObject;
fil:=fso.GetFile(path);
fs:=fil.OpenAsTextStream(ForReading,TristateUseDefault);
xmlFile:=fs.ReadAll;
fs.Close;

http:=CreateComObject(CLASS_WinHttpRequest) as WinHttpRequest;
http.SetTimeouts(10000,10000,10000,10000);
http.Option[WinHttpRequestOption_SslErrorIgnoreFlags]:=13056;
http.Open('POST',url,EmptyParam);
http.SetRequestHeader('Content-Type','text/xml');
http.SetRequestHeader('Content-Length',inttostr(length(xmlFile)));
http.SetCredentials(user,password,0);
http.Send(xmlFile);
statusStr:=http.StatusText;
if statusStr='200' then
begin
ShowMessage('send success');
end
else
begin
ShowMessage('send failed');
end;

except
on err:EOleException do
begin
ShowMessage(err.Message);
end
else
begin
ShowMessage('other error!');
end;
end;
end;
thisworld 2006-06-30
  • 打赏
  • 举报
回复
俺只写过vc++下的https,用的是winsock API+Openssl库,好像微软有个什么组件可以用的,回家我找找

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧