> I'm trying to perform an HTTP post operation, but I can't figure 
> out how to do it with TCPClient. I know I need to change the method 
> from GET to POST:
> 
>       <cfset obj.SendRN("POST /myTest.cfm HTTP/1.0")>
>
> But I don't know how to set the form data.

By default, when form data is sent to a server, it's encoded just like URL
data would be (thus, enctype="application/x-www-form-urlencoded"). So, that
ends up looking like this:

name=Bob%20Smith&address=1400%2016th%20Street

> Also, is it possible to use multiple encoding types, like:
>
>           enctype="text/plain"
>           enctype="multipart/form-data"
>           enctype="application/x-www-form-urlencoded

You can use one encoding type per request. The remote server has to be able
to deal with whatever you're sending; standard CGI interfaces like CF know
how to deal with the two common form POST options listed above.

Now that I've addressed those direct questions, I'll volunteer a piece of
information that should make all this a lot easier for you. Since you're
building "raw" HTTP POSTs, it would be very useful to be able to see what
they look like first. Once you've built the entire string you're going to
send to the remote server, the actual act of sending it with TCPClient is
really trivial.

So, how can you look at a "raw" HTTP POST? Use a recording proxy. The
easiest one I've found for simply reading HTTP data is called Stretch, and
it's available at http://www.kestral.com.au/. Someone on this list pointed
it out to me - it's much easier for casual use than what I was using at the
time.

Just run stretch.exe, enter the name or IP address of the target server,
then point your browser to http://localhost:8080/. If you want to run a
specific file on the remote server, you can point to the appropriate file
path (http://localhost:8080/path/to/myfile.cfm). Stretch will record HTTP
requests and responses, and you can see exactly what's going back and forth.

Dave Watts, CTO, Fig Leaf Software 
http://www.figleaf.com/ 
voice: (202) 797-5496 
fax: (202) 797-5444

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to