🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.web
Article #1694

Re: http - post

#1694
From: Mark Jacobs
Date: Tue, 05 Oct 2004 09:13
68 lines
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.
Technical Details
Message-ID: <416265ae$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4161ea5c$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,edd0e253bad903c5
X-Google-Attributes: gidfeeec,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Mark Jacobs" <http://www.jacobsm.com/mjmsg?Borland%20Newsgroup>
Newsgroups: borland.public.cppbuilder.internet.web
References: <4161ea5c$1@newsgroups.borland.com>
Subject: Re: http - post
Date: Tue, 5 Oct 2004 10:13:56 +0100
Lines: 70
Organization: DK Computing
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 81.144.157.8
Message-ID: <416265ae$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1096967598 81.144.157.8 (5 Oct 2004 02:13:18 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail