简体   繁体   English

Indy http post解码

[英]Indy http post decode

How can I decode & parse a URL so I can use it as POST parameters. 如何解码和解析URL,以便将其用作POST参数。

continue=http%3A%2F%2Fmail.google.com%2Fmail%2F&service=mail&rm=false&dsh=..

var
 URL:String;
 Data:TStringList;
 MemoryStream:TMemoryStream;
begin
IdHTTP1.Post(URL, Data, MemoryStream);

You can do it all with TIdURI : 您可以使用TIdURI完成所有TIdURI

  • To decode use TIdURI.URLDecode(...) . 解码使用TIdURI.URLDecode(...)
  • To parse, pass the decoded URI to TIdURI.Create . 要解析,请将解码后的URI传递给TIdURI.Create

Putting it together you'd have something like this: 把它放在一起就有这样的东西:

var
  URI: TIdURI;
....
URI := TIdURI.Create(TIdURI.URLDecode(EncodedURI));
try
  // Protocol = URI.Protocol
  // Username = URI.Username
  // Password = URI.Password
  // Host = URI.Host
  // Port = URI.Port
  // Path = URI.Path
  // Query = URI.Params
finally
  URI.Free;
end;

With acknowledgement to these answers: 承认这些答案:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM