PDA

View Full Version : Indy 10 - problem with IdHTTP.Get method



Brainer
02-02-2008, 10:44 PM
:arrow: System: Windows XP, Pentium D 3,0 GHz, GeForce 7600 GS
:arrow: Compiler/IDE: Delphi 2007 for Win32
:arrow: API/Packages: Indy 10

Welcome! :)

I've got a problem with IdHTTP.Get method. I use this code to retrieve website's HTML code:

var
S: TMemoryStream;
X: String;
begin
S := TMemoryStream.Create();
X := 'http://www.wikipedia.pl';
try
IdHTTP.Get(X, S);
S.Position := 0;
Memo.Lines.LoadFromStream(S);
finally
S.Free();
end;

And it works perfectly for this website and a few others:


http://szukaj.torrenty.org/szukaj2.php?szukaj=crysis
http://www.animenewsnetwork.com/search?cx=016604166282602569737%3Aznd1ysjewre&cof=FORID%3A11&q=da+capo


But when I try to get the code of this one, it returns some weird ASCII characters:

X := 'http://anidb.net/perl-bin/animedb.pl?show=animelist&adb.search=Darker&do.search=search';


What am I doing wrong? :?
If you need any additional information, please let me know.

Best Regards. :)

EDIT
Problem solved! :D

technomage
03-02-2008, 11:01 AM
Just out of interest what was the problem?

AthenaOfDelphi
03-02-2008, 11:12 AM
For anyone who may have been pondering this one (a quick post to say what was wrong would help others)... the problem was content encoding.

Webservers are supposed to look at the HTTP request headers in order to determine what kind of encoding is acceptable for the response. Normally when surfing with Firefox for example, this will be gzip/deflate (IIRC) and when requesting with the Indy components, its normally blank meaning only plain text is acceptable (IIRC).

This particular webserver was ignoring this field and was gzipping the response regardless.

As a consequence, the client needed to look at the encoding information for the response and take appropriate action... in this case, decompress the response using a gzip library such as Abbrevia.

Brainer
03-02-2008, 03:08 PM
For anyone who may have been pondering this one (a quick post to say what was wrong would help others)... the problem was content encoding
Yes indeed. :) I used TIdCompressorZLibEx to decode the data. My little brother (who is not a programmer) suggested me, that the data is encrypted a look for something to decrypt it. :lol:

Anyway, thank you for your interest! :D Next time I'll write a few words about the solution. ;)