TsgcHTTPServer › 属性 › ParseParams

ParseParams 属性

将每个请求的查询字符串和 form-urlencoded 正文解析到 ARequestInfo.Params 中。

语法

property ParseParams: Boolean read GetParseParams write SetParseParams;

默认值

True

备注

当 ParseParams 为 True(默认值)时,底层的 Indy HTTP 服务器会解码请求的查询字符串,以及对于 application/x-www-form-urlencoded 的 POST 正文而言,还会解码其中的表单字段,从而使每个名称/值对都可以通过 OnCommandGet / OnCommandOther 内的 ARequestInfo.Params 获取。将其设置为 False 可跳过此解析步骤,例如当服务器主要处理直接从 ARequestInfo.PostStream 读取的原始 JSON 或二进制正文时,额外的解析将是无谓的开销。

示例


oServer := TsgcHTTPServer.Create(nil);
oServer.ParseParams := true;

procedure OnCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo;
  AResponseInfo: TIdHTTPResponseInfo);
begin
  AResponseInfo.ContentText := 'name=' + ARequestInfo.Params.Values['name'];
end;

返回属性