| View previous topic :: View next topic |
| Author |
Message |
dpap Guest
|
Posted: Sun Sep 10, 2006 6:05 pm Post subject: idHTTP.Get(filename_with_spaces) |
|
|
Hi,
i use idHTTP component to download files (D7ent, Indy10) with the statement
idHTTP.get(fileName,aStream);
if the fileName includes spaces (or/and characters not in english) the
downloading fails, otherwise works fine.
I use this code a long time ago but i haven't this problem. I saw it after
upgrading from D5 to D7 but i'm not sure because i see it even i run the
older version (compiled with D5) and only from the two of three PCs i've
test it
any idea ?
thanks in advance |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Sep 11, 2006 12:56 am Post subject: Re: idHTTP.Get(filename_with_spaces) |
|
|
dpap wrote:
| Quote: | if the fileName includes spaces (or/and characters not in english) the
downloading fails, otherwise works fine.
|
Try URL encoding (
http://www.blooberry.com/indexdot/html/topics/urlencoding.htm ) for
spaces and other non-url-friendly characters. When using %20 instead
of a space, the http server should convert that to a space on it's side
resulting in a successful get. |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Sep 11, 2006 1:13 am Post subject: Re: idHTTP.Get(filename_with_spaces) |
|
|
fafafooey (AT) gmail (DOT) com wrote:
| Quote: | dpap wrote:
if the fileName includes spaces (or/and characters not in english) the
downloading fails, otherwise works fine.
Try URL encoding (
http://www.blooberry.com/indexdot/html/topics/urlencoding.htm ) for
spaces and other non-url-friendly characters. When using %20 instead
of a space, the http server should convert that to a space on it's side
resulting in a successful get.
|
Actually on second thought, IdHTTP should encode the URL automatically.
You should try and attach a IdLogDebug intercept component on the
IdHTTP and see what GET string is being sent to the HTTP server. You
said "characters not in english" is the the URL...that might have
something to do with it but you won't know until you see the raw data. |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Sep 12, 2006 2:58 am Post subject: Re: idHTTP.Get(filename_with_spaces) |
|
|
"dpap" <dpap (AT) softwaypro (DOT) gr> wrote in message
news:45040d97$1 (AT) newsgroups (DOT) borland.com...
| Quote: | i use idHTTP component to download files (D7ent, Indy10) with the
statement idHTTP.get(fileName,aStream);
if the fileName includes spaces the downloading fails, otherwise works
fine. |
Spaces have to be encoded as '%20' before calling Get().
| Quote: | or characters not in english
|
Unless you are working in .NET, or the URL is encoded using IDNA, then you
cannot use Unicode-based URLs with TIdHTTP at all.
Gambit |
|
| Back to top |
|
 |
dpap Guest
|
Posted: Tue Sep 12, 2006 8:11 am Post subject: Re: idHTTP.Get(filename_with_spaces) |
|
|
Remy thank you
| Quote: |
Spaces have to be encoded as '%20' before calling Get().
i' ll try it immediately |
| Quote: | or characters not in english
Unless you are working in .NET, or the URL is encoded using IDNA, then you
cannot use Unicode-based URLs with TIdHTTP at all.
in my older version (D5/indy9) there aren't these limitations, neither with |
spaces nor with Greek haracters. All are working fine, certified.
How can encode the URL using IDNA ? can you give me an example ?
thanks again |
|
| Back to top |
|
 |
dpap Guest
|
Posted: Tue Sep 12, 2006 1:48 pm Post subject: Re: idHTTP.Get(filename_with_spaces) |
|
|
Remy
| Quote: | Spaces have to be encoded as '%20' before calling Get().
yes it works ! |
| Quote: |
Unless you are working in .NET, or the URL is encoded using IDNA, then you
cannot use Unicode-based URLs with TIdHTTP at all.
|
I was wrong. It works with Greek characters without any modification !
thanks again |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Sep 12, 2006 2:29 pm Post subject: Re: idHTTP.Get(filename_with_spaces) |
|
|
"dpap" <dpap (AT) softwaypro (DOT) gr> wrote in message
news:45065da3 (AT) newsgroups (DOT) borland.com...
| Quote: | in my older version (D5/indy9) there aren't these limitations,
neither with spaces nor with Greek haracters.
|
TIdHTTP's input parameters work the same in Indy 10 as they did in Indy 9.
Encoding spaces as '%20' is an HTTP requirement.
Also, the VCL in general is Ansi-based anyway. Get() accepts an AnsiString,
not a WideString, so it cannot accept Unicode-based URLs.
| Quote: | How can encode the URL using IDNA ?
|
IDNA is not currently implemented in Indy. You will have to implement it
manually in your own code. Unfortunately, it is a complex algorithm to
implement from scratch, which is why it has not been added to Indy yet.
Refer to RFC 3490 for details.
Gambit |
|
| Back to top |
|
 |
dpap Guest
|
Posted: Tue Sep 12, 2006 11:52 pm Post subject: Re: idHTTP.Get(filename_with_spaces) |
|
|
| Quote: |
I was wrong. It works with Greek characters without any modification !
|
I'm getting crazy !
I have two PCs with the same configuration (WinXpsp2,D7ent/Indy10).
Compiling the same code with the same parameters to the two PCs, on the
first, i can download files with Greek characters. On the other i can't
(error message 400)!!.
any help please ? |
|
| Back to top |
|
 |
Guillem Guest
|
Posted: Wed Sep 13, 2006 2:03 pm Post subject: Re: idHTTP.Get(filename_with_spaces) |
|
|
dpap wrote:
| Quote: |
I was wrong. It works with Greek characters without any
modification !
I'm getting crazy !
I have two PCs with the same configuration (WinXpsp2,D7ent/Indy10).
Compiling the same code with the same parameters to the two PCs, on
the first, i can download files with Greek characters. On the other i
can't (error message 400)!!.
any help please ?
|
http error 400 means bad request. Sounds to me like the contents of the
Get request are becoming corrupt in the case of the PC that fails.
Try to use a packet sniffer like Ethereal to determine if this is what
is happening.
--
Best regards :)
Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam |
|
| Back to top |
|
 |
dpap Guest
|
Posted: Thu Sep 14, 2006 11:34 pm Post subject: Re: idHTTP.Get(filename_with_spaces) |
|
|
| Quote: |
http error 400 means bad request. Sounds to me like the contents of the
Get request are becoming corrupt in the case of the PC that fails.
|
No, there are corrupted contents. The server doesn't recognise the filename
written in greek character set, like i had request an unexisted file.
If i ask for any file with name in english (ASCII 32..127) all works fine.
If i rename it (e.g. changing a single char to Greek, ASCII 128..255) i
receive the error 400 Bad request. Inverting the change all works fine
again. All of these at the one PC. At the other PC, any change is
acceptable.
The conditions of the two PCs and the Delphi code/settings are the same and
the file requests are the same.
Isn't this a mystery ?
thanks |
|
| Back to top |
|
 |
Guillem Guest
|
Posted: Fri Sep 15, 2006 8:11 am Post subject: Re: idHTTP.Get(filename_with_spaces) |
|
|
dpap wrote:
| Quote: |
No, there are corrupted contents. The server doesn't recognise the
filename written in greek character set, like i had request an
unexisted file. If i ask for any file with name in english (ASCII
32..127) all works fine. If i rename it (e.g. changing a single char
to Greek, ASCII 128..255) i receive the error 400 Bad request.
Inverting the change all works fine again. All of these at the one
PC. At the other PC, any change is acceptable. The conditions of the
two PCs and the Delphi code/settings are the same and the file
requests are the same. Isn't this a mystery ?
thanks
|
maybe they are working with different character sets?
--
Best regards :)
Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam |
|
| Back to top |
|
 |
dpap Guest
|
Posted: Fri Sep 15, 2006 9:25 pm Post subject: Re: idHTTP.Get(filename_with_spaces) |
|
|
| Quote: |
maybe they are working with different character sets?
|
no, they are configured identically because i must work in the same
environment at office/home. This works for several months.
I try to download the same filename with IE. The same behavior. With latin
characters the downloading goes fine, with greek characters (even one) fails
(404 Not Found, The requested document was not found on this server).
The web server is a Apache server and must hasn't interference because the
problem exists only at my home PCs, one desktop, one lahptop and a
virural/VMWare PC all sharing the same ADSL connection with different ops
(WinXppro,WinXphome,Win98).
I suppose, all these mean that isn't a problem of my application or any
delphi/indy interference or web server nor even windows, but something with
ISP. At my office, i have another ISP provider and no problem.
Is it possible to be some ISP's configuration changes that cause the
problem?
thanks |
|
| Back to top |
|
 |
Guillem Guest
|
Posted: Mon Sep 18, 2006 3:24 pm Post subject: Re: idHTTP.Get(filename_with_spaces) |
|
|
dpap wrote:
| Quote: |
Is it possible to be some ISP's configuration changes that cause the
problem?
|
it could be if they haven't configured the server to accept greek
characters or something got misconfigured/corrupted but this is
something only they can answer.
I would try to use a packet sniffer both at home and at the work and
check if there is any (subtle or not) difference. If not you can always
ask technical help to your ISP for home and send them the sniffer
logs...
Sorry I couldn't be of more help. Good luck
--
Best regards :)
Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam |
|
| Back to top |
|
 |
dpap Guest
|
Posted: Wed Sep 20, 2006 8:11 am Post subject: Re: idHTTP.Get(filename_with_spaces) |
|
|
| Quote: | it could be if they haven't configured the server to accept greek
characters or something got misconfigured/corrupted but this is
something only they can answer.
many thanks for your help. I ask help from my ISP and i'm waiting for it |
|
|
| Back to top |
|
 |
|