【发布时间】:2020-04-17 20:48:05
【问题描述】:
我有 Delphi Web 服务,使用 TWebModule.. 但是,我对 HTTP/HTPPS 有疑问。 我无法将请求 http 重定向到 https。
你能帮帮我吗?
【问题讨论】:
标签: delphi delphi-xe8
我有 Delphi Web 服务,使用 TWebModule.. 但是,我对 HTTP/HTPPS 有疑问。 我无法将请求 http 重定向到 https。
你能帮帮我吗?
【问题讨论】:
标签: delphi delphi-xe8
这很容易。在 WebModuleUnit 中键入以下内容:
procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
if Request.QueryFields.Values['proto'] = 'http' then
if Request.QueryFields.Values['target'] <> '' then
Response.SendRedirect('https://' + Request.QueryFields.Values['target'])
else
Response.Content := '<HTML><BODY>Invalid URI</BODY></HTML>';
Response.Content :=
'<html>' +
'<head><title>DataSnap Server</title></head>' +
'<body>DataSnap Server</body>' +
'</html>';
end;
【讨论】: