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 热键声明和使用

解放程序员!Delphi带来app开发革命

Delphi中多线程下使用使用 unidac+mssql 需要注意的问题

Delphi程序升级到64位

Delphi 得到字符串拼音首字母

Delphi 读取文件的md5值

Delphi xe程序的主题(theme)设置

Delphi远程开机再配合远程控制

Delphi嵌入循环汇编

Delphi中显示gif动画

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



打赏

取消

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

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

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

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

评论

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