Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Apr : IdPost Parameter Encoding Issue

www.cryer.info
Managed Newsgroup Archive

IdPost Parameter Encoding Issue

Subject:IdPost Parameter Encoding Issue
Posted by:"Stephen Done" (no.spam@no.spam.com)
Date:12 Apr 2008 05:05:19

I am using IdHttp for a post and everything is working fine except for one thing. Here is the most basic example I can make of my problem. I want to replicate this form post...

<html>
<body>
  <form method=post action=test.asp>
    <input type=text name=testparam value="dog&cat+fish">
    <input type=submit name=submit>
  </form>
</body>
</html>

I have an ASP page that correctly displays the retrieved text string "dog&cat+fish" as posted by the above web page.
Here's some example asp...

Response.Write "<pre>"
Response.Write "testparam=" & Request.Form("testparam") & vbCRLF

The output from the ASP page when the above form is submitted is

    dog&cat+fish

Now how do you do this with IdHttp ?
I have the post working fine, so long as the user doesn't use '+' or '&' in their string.
It is the correct encoding of the the string that I have a problem with.

var
  PostData:TIdStrings
begin
...
  PostData.Clear;
  PostData.Add('testparam=dog&cat+fish');
  Response := MyIdHttp.Post(URL, PostData);
end;

I have traced the code, and TIdURI.ParamsEncode(const ASrc: string): string; is being called,
however what it lists as unsafe parameter characters is ['*', '#', '%', '<', '>', ' ','[',']'] and does not include '&','+'

So my question is, rather than modifying TIdURI.ParamsEncode to add '&','+', what is the correct way to achieve what the browser does as standard ?

Thanks for any help.

Steve

Replies:

www.cryer.info
Managed Newsgroup Archive