Board index » delphi » ParamsEncode problems and misc questions...

ParamsEncode problems and misc questions...


2005-10-07 09:08:00 AM
delphi17
Do there exist any Indy functions that can tell me (e.g. by looking
in hosts file etc.) if the uri I have is with localhost or local network?
(currently I am using my own that searches for "localhost/" matching first
"/" after "http://")
I have a problem with TIdURI.ParamsEncode
I am fiddling with validating .css files through W3C's validator
For comparison purposes, here is the original css string (the beginning):
"/*
div.somethin"
My code looks something like:
"
TmpWebpageContentStr := TIdURI.ParamsEncode(TmpWebpageContentStr);
TmpCallStr := 'jigsaw.w3.org/css-validator/validator +
TmpWebpageContentStr;
"
However, this does not seem to work... Submitting "live" in e.g. IE creates
pathes like:
jigsaw.w3.org/css-validator/validator
while Indy creates:
jigsaw.w3.org/css-validator/validator
It would seem one converts the "/" while the other the "*" :And:
ParamsEncode does, contrary to help, not convert space to '+'.
(not that I understand why anyone would use '+' instead of %20 ?)
Could anyone tell me:
a) what's wrong :-))
b.1) perhaps guide me to a quick primer for uri encoding on the net...
b.2) because next thing I plan to try is to "post" content to
validator.w3.org
(even though... I /think/ Indy encodes that as needed... at least what I've
read...
Still, I haven't tested that yet).
best regards
Thomas Schulz
 
 

Re:ParamsEncode problems and misc questions...

"dk_sz" <XXXX@XXXXX.COM>writes
Quote
Do there exist any Indy functions that can tell me (e.g. by
looking in hosts file etc.) if the uri I have is with localhost or
local network?
Not specifically for that particular purpose, no. But you can create a
TIdURI instance, pass the URL to it for parsing, and then see what the
TIdURI.Host property is set to. 'localhost' or '127.0.0.1' represent the
local machine. You may also have to check the machine's actual IP address
as well, which is available in the global GStack.LocalAddress property.
Quote
I have a problem with TIdURI.ParamsEncode
Have you tried using URLEncode() instead of ParamsEncode()? You are posing
data via a URL, afterall.
Gambit
 

Re:ParamsEncode problems and misc questions...

Quote
TIdURI instance, pass the URL to it for parsing, and then see what the
TIdURI.Host property is set to. 'localhost' or '127.0.0.1' represent the
I need it to detect if I can pass a uri directly to (for my tests) W3C. The
alternative
is to fetch the data myself (if e.g. localhost), and then pass the data to
W3C.
Quote
Have you tried using URLEncode() instead of ParamsEncode()? You are
posing
data via a URL, afterall.
I am... But then again, the data is passed in the params segment
so... Well, I will admit I were a little in doubt which to use:-)
Under all circumstances, I sorta have! But TidURI.Encode throws
an exception when setting Result := URI; (-->GetURI) -->
"
function TIdURI.GetFullURI(const AOptionalFields: TIdURIOptionalFieldsSet):
String;
...
if FProtocol = '' then begin
raise EIdURIException.Create(RSURINoProto);
"
Anyways, I have tryed both: PathEncode and ParamsEncode
(the code difference seems minimal though). they return the same:
I tryed with "body { margin: 7px; }":
Indy ParamsEncode: body%20{%20margin:%207px;%20}%0D%0A%0D%0A%0D%0A
Indy PathEncode: body%20{%20margin:%207px;%20}%0D%0A%0D%0A%0D%0A
IE: body+%7B+margin%3A+7px%3B+%7D
FireFox: body+%7B+margin%3A+7px%3B+%7D
So... What to do, I do not know...
I could make my own routine of course...
Still - that seems borderline to silly :-)
best regards
Thomas Schulz
 

Re:ParamsEncode problems and misc questions...

"dk_sz" <XXXX@XXXXX.COM>writes
Quote
I am... But then again, the data is passed in the params segment so...
The data is still in the URL nonetheless. ParamsEncode() is not meant to be
used for URLs. It is meant to be used for params that are posted to the
server in a separate data stream, not when the params are in the URL
directly. That is what URLEncode() is for instead.
Gambit
 

Re:ParamsEncode problems and misc questions...

Quote
The data is still in the URL nonetheless. ParamsEncode() is not meant to
be
used for URLs. It is meant to be used for params that are posted to the
server in a separate data stream, not when the params are in the URL
directly. That is what URLEncode() is for instead.
Thanks for the clarification!
BTW, I found something called WebUtil made by
someone called Danny (it's freeware with source)
www.delphi32.com/vcl/4884/
Seems to work the way I want it.
best regards
Thomas