Delphi 纯Window系统API实现的SSL客户端


本文整理自网络,侵删。

 
program Project1;

{$APPTYPE CONSOLE}

uses
  Winapi.Windows,
  Unit_SSL in 'Unit_SSL.pas';

Const
  pSend :PAnsiChar = 'GET / HTTP/1.1' + #13#10 +
  'Host: github.com' + #13#10 +
  'User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko' + #13#10 +
  'Accept:*/*' + #13#10#13#10;
Var
  lpSSL  :TSSL_Socket;
  Buffer :PAnsiChar;
begin
  lpSSL := TSSL_Socket.Create;
  lpSSL.UseSSL := True;
  lpSSL.Connect('github.com', 443);
  if lpSSL.Connected then
  begin
    If lpSSL.Send(pSend, lstrlenA(pSend)) > 0 Then
    begin
      Buffer := GetMemory(1024 * 1024 * 64);
      lpSSL.Recv(Buffer, 1024 * 1024 * 64);
      Writeln(Buffer);
      FreeMemory(Buffer);
    end;
    lpSSL.Disconnect;
  end;
  lpSSL.Free;
  Readln;
end.

来源:https://www.7xcode.com/archives/115.html

相关阅读 >>

Delphi中tstringlist分割字符串的用法

Delphi cannot find implementation of method formcreate 解决办法

进程防杀Delphi版(dll部分)

Delphi 限制文本框中只接受数字

Delphi 手机app打开一个安卓系统支持的文件,比如 pdf

获取网络日期

Delphii控件的安装和卸载方法

Delphi向当前窗口模拟键盘ctrl+v发送"粘贴"

Delphi 中 使用 tidhttp 提交post数据

Delphi 遍历文件单元文件

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...