TsgcHTTP3Client › 方法 › Post

Post 方法

发送携带正文负载的同步 HTTP/3 POST 请求并返回响应体。

语法

function Post(const aURL: string; const aData: string; const aContentType: string = 'application/x-www-form-urlencoded'): string;

参数

名称类型描述
aURLconst string请求发送目标资源的绝对 URL。
aDataconst string发送给服务器的请求正文。
aContentTypeconst stringcontent-type 标头的值。默认为 application/x-www-form-urlencoded。

返回值

从服务器接收的响应体,解码为字符串。(string)

备注

Post 阻塞调用线程直至收到完整的 HTTP/3 响应,并以字符串形式返回正文。将 aContentType 设为与负载匹配的值,例如发送 JSON 文档时设为 application/json。如需非阻塞请求,请使用 PostAsync,它将回复传递到 OnResponse。

示例


vResponse := oClient.Post('https://api.example.com/v1/login', 'user=john&pass=secret');

返回方法