Thread View: borland.public.cppbuilder.internet.web
6 messages
6 total messages
Started by JF
Tue, 05 Oct 2004 00:25
http - post
Author: JF
Date: Tue, 05 Oct 2004 00:25
Date: Tue, 05 Oct 2004 00:25
22 lines
1671 bytes
1671 bytes
Making my first venture into generating data for the parameters for an http->post using C++builder 5. The post data I created as a first test was simply "name= John". The first target URL was a small asp program on localhost which does a response.write of each key and each request.form key. This program thinks key (name) is "name=John" and response.write key (value) is nothing. The second target URL was www.uark.edu/~wrgx/versus/post.cgi which shows all the parameters that were sent to it. This site thought the key was "name%3dJohn". Both inputfilemode and outputfilemode are set to false. In both cases the data from the site was viewed through the code Memo1->Text=NMHTTP1->Body; What should I have written in the postdata parameter?Any help or pointers to a source of information would be greatly appreciated. JF
Re: http - post
Author: Remy Lebeau (TeamB)
Date: Tue, 05 Oct 2004 01:37
Date: Tue, 05 Oct 2004 01:37
10 lines
1078 bytes
1078 bytes
"JF" <john.forbes@shaw.ca> wrote in message news:4161ea5c$1@newsgroups.borland.com... > What should I have written in the postdata parameter? It would help if you would show what you are already using first. Gambit
Re: http - post
Author: JF
Date: Tue, 05 Oct 2004 02:31
Date: Tue, 05 Oct 2004 02:31
28 lines
1589 bytes
1589 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:4161fad1$1@newsgroups.borland.com...
>
> "JF" <john.forbes@shaw.ca> wrote in message
> news:4161ea5c$1@newsgroups.borland.com...
>
> > What should I have written in the postdata parameter?
>
> It would help if you would show what you are already using first.
>
>
> Gambit
>
>
Thanks for responding so quickly.
My first try was:-
NMHTTP1->Post("http://localhost.asptest.asp","name=John");.
This produced the results described in the first post to the group.
Or did you want/need some different info. In which case could you say what
you mean by 'what you are already using'?
Thanks for your help.
JF
Re: http - post
Author: Remy Lebeau (TeamB)
Date: Tue, 05 Oct 2004 06:23
Date: Tue, 05 Oct 2004 06:23
14 lines
1437 bytes
1437 bytes
"JF" <john.forbes@shaw.ca> wrote in message
news:416207fe@newsgroups.borland.com...
> NMHTTP1->Post("http://localhost.asptest.asp","name=John");.
The Netmaster components are buggy and problematic in general. You would be
better off switching to a different component altogether, such as the HTTP
client found in either Indy (http://www.indyproject.org) or ICS
(http://www.overbyte.be), amongst many other third-party HTTP
implementations that are available.
Gambit
Re: http - post
Author: Hans Galema
Date: Tue, 05 Oct 2004 07:20
Date: Tue, 05 Oct 2004 07:20
38 lines
2213 bytes
2213 bytes
JF wrote: > The post data I created as a first test was simply "name= John". That is no good idea. Better make it "name=John". > The first target URL was a small asp program on localhost which does a > response.write of each key and each request.form key. This program thinks > key (name) is "name=John" and response.write key (value) is nothing. What kind of asp program is that ? Isn't there a webserver ? If it is an asp script, who wrote it ? > The second target URL was www.uark.edu/~wrgx/versus/post.cgi which shows all > the parameters that were sent to it. This site thought the key was > "name%3dJohn". Wasn't it "name%3DJohn" ? That is perfectly ok. The site states as such: "The data is encoded with + sign's and %(hex equivalents).". "%3D" means "=". It is URL encoded. > In both cases the data from the site was viewed through the code > Memo1->Text=NMHTTP1->Body; I did that too. But you better copy and paste it to wordpad because of the linebreaks. While testing better send two key=value pairs. > What should I have written in the postdata parameter? It was ok. I tested again TNMHTTP posting to some of my webapplications. It does the job. Hans.
Re: http - post
Author: Mark Jacobs
Date: Tue, 05 Oct 2004 09:13
Date: Tue, 05 Oct 2004 09:13
68 lines
3304 bytes
3304 bytes
The server which receives the info is going to get it "url-encoded", a scheme
used to send characters possibly not supported by all "teletypes" in an
encoded form (a percent sign followed by the hex ascii value of the
character). The server will have to decode it, because it is encoded by the
http protocol. For completeness, I attach a couple of routines for handling
the encoding :-
AnsiString mjunescape(AnsiString webstr)
{
int ii,jj=webstr.Length(),kk,mm; AnsiString
retv="",pschs="0123456789ABCDEF"; char ch;
for (ii=1;ii<=jj;++ii)
{
ch=webstr[ii]; if (ch=='+') { retv+=" "; continue;}
if (ch!='%') { retv+=ch; continue;}
if (ii<jj) if (webstr[ii+1]=='%') { retv+="%"; ++ii; continue;}
if (ii<jj-1)
{
kk=pschs.Pos((char)toupper(webstr[ii+1]));
mm=pschs.Pos((char)toupper(webstr[ii+2]));
if (kk>0 && mm>0) { retv+=(char)((kk-1)*16+mm-1); ii+=2;} else retv+=ch;
}
}
return retv;
}
AnsiString mjescape(AnsiString webstr)
{
int ii,jj=webstr.Length(); AnsiString retv=""; char ch;
AnsiString
pschs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789*@._-$!'(
)%";
for (ii=1;ii<=jj;++ii)
{
ch=webstr[ii]; if (ch==' ') { retv+="+"; continue;}
if (pschs.Pos(ch)>0) retv+=ch; else retv+="%"+IntToHex(ch,2);
}
return retv;
}
HTH
--
Mark Jacobs
DK Computing
http://www.dkcomputing.co.uk
"JF" <john.forbes@shaw.ca> wrote in message
news:4161ea5c$1@newsgroups.borland.com...
| Making my first venture into generating data for the parameters for an
| http->post using C++builder 5.
|
| The post data I created as a first test was simply "name= John".
|
| The first target URL was a small asp program on localhost which does a
| response.write of each key and each request.form key. This program thinks
| key (name) is "name=John" and response.write key (value) is nothing.
|
| The second target URL was www.uark.edu/~wrgx/versus/post.cgi which shows all
| the parameters that were sent to it. This site thought the key was
| "name%3dJohn".
|
| Both inputfilemode and outputfilemode are set to false.
|
| In both cases the data from the site was viewed through the code
| Memo1->Text=NMHTTP1->Body;
|
| What should I have written in the postdata parameter?Any help or pointers to
| a source of information would be greatly appreciated.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads