Board index » delphi » TIdHttp.Get and redirection

TIdHttp.Get and redirection


2003-08-11 07:22:01 PM
delphi180
Hi,
I'm using the following steps to verify an URL and a possible redirection.
E.g.:
1) IdHTTP.Get('www.mhst.net/mailingliste').
2) Get aware of a redirection in IdHTTP.Response.Location :
'www.mhst.net/mailinglist'. (without letter 'e'!)
3) A refresh is triggered (<META HTTP-EQUIV="Refresh" CONTENT="0;
URL=www.mhst.net/downloads">)
Step 3) is not handled by Indy so a next step follows:
4) IdHTTP.Get(IdHTTP.Response.Location).
Afterwards sometimes FIdHTTP.Response.HasContentLength is true and sometimes
not. *.ContentStream is <>Nil* but when I try to read from the stream I get
an AV. This is true if I only check for ContentStream.Size <>0.
I've found out when using IdHTTP.Disconnect between 3) and 4),
HasContentLength is always true!
What's going on here and how can I get the content of the new, 2nd URL
'www.mhst.net/mailinglist' to search it for the META tag?
It also seems that subsequent .Get()'s do not work?
cu,
Michael
 
 

Re:TIdHttp.Get and redirection

A further question still left:
The URL www.msn.de/default.asp will be redirected and
IdHTTP.Response.Location reads: /global/incompbrowser.asp afterwards.
How do I have to read this URL in a complete manner:
www.msn.de/global/incompbrowser.asp ? Since e.g. in IE the above,
first, URL does not change. However when using
www.msn.de/global/incompbrowser.asp in IE I get an error page!
cu,
Michael
 

Re:TIdHttp.Get and redirection

Quote
try
if FIdHTTP.Response.Location <>FCurrentURL then
html := LowerCase(FIdHTTP.Get(FIdHTTP.Response.Location));
except
end;
However the problem is that I do not get any results back from FIdHttp. The
LowerCase only works of course when Get() returns some data in my special
case.
Quote
BTW, doing an explicit string search like this is not the best way to
search
for <meta>tags. You really should be parsing the actual HTML and
tokenizing it properly. HTML tag attributes could potentially be in any
order, text case, extra whitespace, etc.
Does Indy provide such a parser?
Thanks,
Michael
 

Re:TIdHttp.Get and redirection

"Michael Fritz" <XXXX@XXXXX.COM>writes
Quote
However the problem is that I do not get any results back from FIdHttp.
The data is there on the server, so I'd suspect that you are not
requesting the correct URL to begin with. What exactly is Response.Location
actually set to at the time it fails?
Quote
Does Indy provide such a parser?
No. HTML parsing is beyond Indy's focus, which is strictly about sockets
and and communications. There are plenty of third-party HTML parsers
available elsewhere, however.
Gambit
 

Re:TIdHttp.Get and redirection

Quote
The data is there on the server, so I'd suspect that you are not
requesting the correct URL to begin with. What exactly is
Response.Location
actually set to at the time it fails?
Remy,
I've already found the solution as posted in atozedsoftware.indy.general
Thanks for your endurance in answering to my problems.
Michael