Can't access this using IdHTTP, am i missing some parameter?

Can't access this using IdHTTP, am i missing some parameter?

Post by Hon Yuen, » Sat, 10 Jan 2004 13:07:31


hi

I come accross with a link that i couldn't access with normal IdHTTP. I can
download this using browser, I suspect that there are some header's
parameters which i have to fill in. Any input?

the URL is
http://www.yqcomputer.com/

what i did is only

idHTTP1.Head(' http://www.yqcomputer.com/ ');

Thanks in advance.

From,
Hon Yuen, Ng
 
 
 

Can't access this using IdHTTP, am i missing some parameter?

Post by Team » Sat, 10 Jan 2004 14:25:44


That retreives the header values for the file, it does not download the file
itself. It you want to download the actual file, you need to call Get()
instead of Head(), ie:

var
Strm: TFileStream;
begin
Strm := TFileStream.Create('c:\ehtml2_2.exe', fmCreate);
try

idHTTP1.Get(' http://www.yqcomputer.com/ ', Strm);
finally
Strm.Free;
end;
end;


Gambit

 
 
 

Can't access this using IdHTTP, am i missing some parameter?

Post by Hon Yuen, » Sun, 11 Jan 2004 11:03:23

Thanks for your reply.

Sorry, maybe i did not put myself clearly.
I tried accessed the file as well as try downloaded it and failed miserably.
:(

the URL is still the same
http://www.yqcomputer.com/

and the code is something similiar to what Remy posted.

idHTTP.Get( http://www.yqcomputer.com/ ,
SomeStream);

The return exception states that the file is not found. I tried download
that file using normal browser, and the file is downloaded succesfully.

My question is,
1. What did i miss here? Do i need to provide some paramter to the Request
part in order to download this file? (Referer, User Agent?)

Thanks in advance.
From,
Hon Yuen, Nf
 
 
 

Can't access this using IdHTTP, am i missing some parameter?

Post by Team » Sun, 11 Jan 2004 11:21:11


How are you constructing 'SomeStream' exactly? Please show a more complete
code snippet.


If the server is saying that the file is not found, then it really is not
found. Double-check your URL. Otherwise accept that you tried to access a
non-existant file and move on.

When I try the code, it works fine for me.


Nothing.


No.


Gambit
 
 
 

Can't access this using IdHTTP, am i missing some parameter?

Post by Hon Yuen, » Mon, 12 Jan 2004 09:30:51

Thanks for the reply.

I think i found out the problem.
I think i did not set the HandleRedirect to true, which, when the client
accesses the server and couldn't find the file it requests, the client did
not redirect accordingly.
Everything seems to work fine after i set the HandleRedirect to true.
However if i dont set it, here are the returned exceptions:

(When checking file header)
EIdHTTPProtocolException HTTP/1.1 404 Not found

(When downloading file)
EIdHTTPProtocolException HTTP/1.1 301 Moved Permanently

Thanks for all the help. Please correct me if i made any wrong assumption.

From,
Hon Yuen, Ng