【发布时间】:2023-03-17 08:51:01
【问题描述】:
我尝试使用TRESTClient 连接到使用 TLS 1.2 的 HTTPS Web 服务。但是发送multipart/form-data 没有运气。
所以现在我正在尝试使用 Indy。我收到了这个“错误的版本号”错误。
我认为代码没有任何问题,因为它与 HTTP 一起使用。
可能我的 Delphi 缺少一些东西。我应该安装什么以及如何安装?
procedure TForm10.Button2Click(Sender: TObject);
var
HTTP: TIdHTTP;
RequestBody: TStream;
ResponseBody: string;
myssl: TIdSSLIOHandlerSocketOpenSSL;
Input: TIdMultipartFormDataStream;
begin
ResponseBody := '';
try
try
HTTP := TIdHTTP.Create;
try
Input := TIdMultipartFormDataStream.Create;
try
Input.Clear;
Input.AddFormField('Email', 'xx@xx.com.tr');
Input.AddFormField('Password', 'xx');
myssl := TIdSSLIOHandlerSocketOpenSSL.Create(HTTP);
HTTP.IOHandler := myssl;
myssl.SSLOptions.Mode := sslmUnassigned;
myssl.SSLOptions.Method := sslvTLSv1_2;
myssl.SSLOptions.SSLVersions := [sslvTLSv1_2];
HTTP.HTTPOptions := [hoForceEncodeParams];
HTTP.Request.CustomHeaders.FoldLines := False;
ResponseBody := HTTP.Post('https://xxx.com.tr/api/Mobile/MobileLoginControl', Input);
finally
Input.Free;
end;
finally
HTTP.Free;
end;
finally
end;
except
ResponseBody := '"-20"';
end;
end;
【问题讨论】:
标签: delphi multipartform-data firemonkey tls1.2 indy