Indy EidHTTPProtocolException?
Indy EidHTTPProtocolException?
I use TIdHTTP to download an image from a web location to a memorystream.
I use the following code:
tmpMemStream:=TMemoryStream.Create;
try
tmpIdHTTP:=tidHttp.create;
try
tmpURL:='http://logo.clearbit.com/'+tmpURL;
tmpIdHTTP.Get('http://(proper url)', tmpMemStream);
tmpLogo:=TBitmap.Create;
tmpLogo.LoadFromStream(tmpMemStream);
finally
tmpIdHTTP.Free;
end;
finally
logo:=tmpLogo;
tmpMemStream.Free;
end;
The above code used to work for a few years but recently I realised that it generates an EIdHTTPProtocolException with the following error:"HTTP/1.1 301 Moved Permanently"
When I try the URL in my browser, the image shows correctly but my code fails. Any ideas what may be wrong?
Thanks
I use TIdHTTP to download an image from a web location to a memorystream.
I use the following code:
tmpMemStream:=TMemoryStream.Create;
try
tmpIdHTTP:=tidHttp.create;
try
tmpURL:='http://logo.clearbit.com/'+tmpURL;
tmpIdHTTP.Get('http://(proper url)', tmpMemStream);
tmpLogo:=TBitmap.Create;
tmpLogo.LoadFromStream(tmpMemStream);
finally
tmpIdHTTP.Free;
end;
finally
logo:=tmpLogo;
tmpMemStream.Free;
end;
The above code used to work for a few years but recently I realised that it generates an EIdHTTPProtocolException with the following error:"HTTP/1.1 301 Moved Permanently"
When I try the URL in my browser, the image shows correctly but my code fails. Any ideas what may be wrong?
Thanks
Maybe HandleRedirects := true ?
ReplyDeleteAlexander Sviridenkov That's it. Thanks :-)
ReplyDelete