Casady
asked on
Using IdHTTP1.Get with Delphi and Indy 9/10 on a specific web server returns exception
I've a problem receiving a favicon.ico from a specific web server using Delphi and Indy 9/10. Other servers do work fine. The problem is not with this web server, as wget command line utility gets the file correctly.
here is the output from wget:
s := IdHTTP1.Get('http://www.google.com/favicon.ico');
everything works just fine.
Is there a workaround to get the http://perforce.eigenbase.org:8080/favicon.icoĀ file using IdHTTP1.Get from the server?
here is the output from wget:
c:\a>wget http://perforce.eigenbase.org:8080/favicon.ico
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = c:/progra~1/wget/etc/wgetrc
--2013-01-27 00:12:39-- http://perforce.eigenbase.org:8080/favicon.ico
Resolving perforce.eigenbase.org... 72.14.190.177
Connecting to perforce.eigenbase.org|72.14.190.177|:8080... connected.
HTTP request sent, awaiting response... 200 No headers, assuming HTTP/0.9
Length: unspecified
Saving to: `favicon.ico'
[ <=> ] 2.862 --.-K/s in 0s
2013-01-27 00:12:40 (143 MB/s) - `favicon.ico' saved [2862]
Here is my Delphi Indy 9/10 example code. It generates a "Connection Closed Gracefully" Exception, and the result is an empty string.procedure TForm1.Button1Click(Sender: TObject);
var s: string;
begin
s := '';
try
s := IdHTTP1.Get('http://perforce.eigenbase.org:8080/favicon.ico');
except
on E: Exception do
begin
{$IFDEF DEBUG}ShowMessage('get error:'+E.Message){$ENDIF};
end;
end;
ShowMessage(IntToStr(Length(s)));
end;
If I try the same code with a different server, for example:s := IdHTTP1.Get('http://www.google.com/favicon.ico');
everything works just fine.
Is there a workaround to get the http://perforce.eigenbase.org:8080/favicon.icoĀ file using IdHTTP1.Get from the server?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
As I said ... it is a pain... Try to use something else which works fine... Other way to download file:
http://www.swissdelphicent er.ch/torr y/showcode .php?id=41 2
http://delphi.about.com/od /interneti ntranet/a/ get_file_n et.htm
http://www.swissdelphicent
http://delphi.about.com/od
ASKER
On the first look it works ok, because I've compared the first 20 bytes of the data I receive with wget and the data in IdHTTP1.ResponseText.
But the wget file is 2862 bytes, the content of IdHTTP1.ResponseText is only 2316 bytes. :(