|
|
导航: |
论坛 -> DELPHI技术
斑竹:liumazi,sephil |
|
作者: |
|
2023/5/22 14:20:42 |
标题: |
使用TNetHTTPClient.Post数据失败,求助!!! |
浏览:323 |
|
加入我的收藏 |
楼主: |
var vHttp: TNetHTTPClient; vS: TStringStream; vList: TStrings; begin vHttp := TNetHTTPClient.Create(nil); vList := TStringList.Create; vS := TStringStream.Create; try Memo1.Lines.Add('----------Post阻塞----------'); vS.Clear;
with vHttp do begin ConnectionTimeout := 2000; // 2秒 ResponseTimeout := 10000; // 10秒 AcceptCharSet := 'utf-8'; AcceptEncoding := '65001'; AcceptLanguage := 'zh-CN'; ContentType := 'application/x-www-form-urlencoded'; UserAgent := 'Embarcadero URI Client/1.0';
vList.Clear; vList.Values['act'] := 'order'; vList.Values['datatype'] := 'json'; vList.Values['date'] := '2023-05-20'; try Post(' https://www.pzz123.com/webctrl.php', vList, vS); // utf8进gbk出 // Memo1.Lines.Add('post:' + TNetEncoding.URL.UrlDecode(vS.DataString)); Memo1.Lines.Add('post:' + vS.DataString); except on E: Exception do // Error sending data: (12002) 操作超时. // Error receiving data: (12002) 操作超时 if Copy(E.Message, 1, Pos(':', E.Message) - 1) = 'Error sending data' then Memo1.Lines.Add('post:连接失败!') else if Copy(E.Message, 1, Pos(':', E.Message) - 1) = 'Error receiving data' then Memo1.Lines.Add('post:接收失败,请延长接收超时时间!') else Memo1.Lines.Add('post:' + E.Message); end; end; finally vS.Free; vList.Free; vHttp.Free; end; end;
认证方式 bearer auth认证 token key
Project Project1.exe raised exception class ENetHTTPClientException with message 'Error sending data: (12175) 发生了安全错误'.
----------------------------------------------
123 |
作者: |
lsuper (lsuper) |
★☆☆☆☆ |
-
|
盒子活跃会员 |
|
2023/5/22 16:15:04 |
1楼: |
HTTP TLS 证书问题,https://synaptica.info/en/2022/05/16/delphi-11-1-nethttpclient-security-error-12175-on-old-windows-system/
----------------------------------------------
-
|
|