gpt4 book ai didi

delphi - 使用Indy下载时出现 "302 Found"异常该怎么办?

转载 作者:行者123 更新时间:2023-12-03 15:05:48 26 4
gpt4 key购买 nike

我正在尝试将文件下载到字符串:

function FetchUrl(const url: string): string;
var
idhttp : TIdHTTP;
begin
idhttp := TIdHTTP.Create(nil);
try
Result := idhttp.Get(url);
finally
idhttp.Free;
end;
end;

这段代码有什么问题?我收到异常:HTTP/1.1 302 Found

最佳答案

TIdHTTP.HandleRedirects 属性设置为 True。默认情况下为 False。

function FetchUrl(const url: string): string; 
var
idhttp : TIdHTTP;
begin
idhttp := TIdHTTP.Create(nil);
try
idhttp.HandleRedirects := True;
Result := idhttp.Get(url);
finally
idhttp.Free;
end;
end;

关于delphi - 使用Indy下载时出现 "302 Found"异常该怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8577900/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com