Board index » delphi » Indy newbie problems

Indy newbie problems


2005-12-22 01:16:51 AM
delphi149
I need to transfer files form a web server virtual folder in my
D6 app.
Someone (Liz the Brit) kindly posted some sample code that
suggested it was very easy and I include below my 'translation'
of it.
output := tfilestream.create('temp.jpg', fmCreate);
try
idhttp1.get('http://217.###.xxx.81/samspics/2540/2540668 -
idPic0.jpg', output);
finally
idhttp1.Disconnect;
output.free;
end;
The string (with ### etc substituted with real numbers) in the
idhttp1.get works in ie or just in run ftm - so I know the file
and path are correct - but I get the error Http 1.1 400 Bad
Request.
Pat Bell
 
 

Re:Indy newbie problems

Quote
Someone (Liz the Brit) kindly posted some sample code that
suggested it was very easy and I include below my 'translation'
of it.

output := tfilestream.create('temp.jpg', fmCreate);
try
idhttp1.get('http://217.###.xxx.81/samspics/2540/2540668 -
idPic0.jpg', output);
finally
idhttp1.Disconnect;
output.free;
end;

The string (with ### etc substituted with real numbers) in the
idhttp1.get works in ie or just in run ftm - so I know the file
and path are correct - but I get the error Http 1.1 400 Bad
Request.
I'm not sure with Indy, but with ICS, you have to url-encode the request.
That is replace all url invalid characters such as spaces by their escaped
value (character percent followed by 2 digit hex code).
http://217.###.xxx.81/samspics/2540/2540668 - idPic0.jpg
becomes
http://217.###.xxx.81/samspics/2540/2540668%20%2D%20idPic0.jpg
ICS (and probably Indy) has an UrlEncode function which does that for you.
--
Contribute to the SSL Effort. Visit www.overbyte.be/eng/ssl.html
 

Re:Indy newbie problems

P.S.Bell writes:
Quote
I need to transfer files form a web server virtual folder in my
D6 app.

Someone (Liz the Brit) kindly posted some sample code that
suggested it was very easy and I include below my 'translation'
of it.

output := tfilestream.create('temp.jpg', fmCreate);
try
idhttp1.get('http://217.###.xxx.81/samspics/2540/2540668 -
idPic0.jpg', output);
finally
idhttp1.Disconnect;
output.free;
end;

The string (with ### etc substituted with real numbers) in the
idhttp1.get works in ie or just in run ftm - so I know the file
and path are correct - but I get the error Http 1.1 400 Bad
Request.



Pat Bell
have you installed the latest Indy dev snapshot?
www.indyproject.org/Sockets/Download/DevSnapshot.en.iwp
--
Best regards :)
Guillem Vicens Meier
Dep. Informática Green Service S.A.
www.clubgreenoasis.com
Contribute to the Indy Docs project: docs.indyproject.org
In order to contact me remove the -nospam
 

Re:Indy newbie problems

Francois PIETTE [ICS - MidWare] writes:
Quote
ICS (and probably Indy) has an UrlEncode function which does that for you.
Yes, it does. IdURL or something like that.
--
Holger
Blog: delphi2006.blogspot.com