wwHTTP::AddPostkey

Adds a POST key and value pair to be used in a POST operation with HTTPGet and HTTPGetEx().

POST data is the main mechanism that HTTP uses to send data from the client to the server. POST data typically gets encoded on the client and then sent up to the server. Several different mechanisms are available:

Web Connection supports all three conntent types through the nHTTPPostMode property setting. If you wish to post a raw or binary buffer you can simply pass a single parameter to AddPostKey with the value and it gets written as is.

HTTP File Uploads are supported via the tlFileName parameter which specifies a file to upload to the server. Make sure you use nHTTPPostMode=2 to specify multipart forms be created in the POST buffer.

o.AddPostKey(tcKey, tcValue, tlIsFile)

Return Value

nothing

Parameters

tcKey
The key value to set. One special value can also be used:

RESET - clears any existing POST data. No value is required to be passed in this case. If you call AddPostKey with no paramters at all the POST buffer is also cleared.

BLANK - ("" or omitted) if this value is empty or not provided tcValue will be used to write the entire POST buffer unencoded. Use for XML documents or anything where you need to post a raw POST buffer.

tcValue
The value to set the key to. In combination these values are equivalent to a Form Variable name and value.

tlIsFile
If this value is set to .T. the second parameter is a filename on disk that is to be uploaded to the Server. NOTE: This only works if nHTTPPostMode = 2 otherwise this option is omitted.

Remarks

UrlEncoded content that is longer than 254 characters requires wwIPStuff.dll for the URLEncoding using C++ code for better performance. This refers to the default nHttpPostMode value of 1.

Depending on the value of the nHTTPPostMode property forms are posted either in standard URLEncoded or Multi-Part form mode. Multi-part form mode can be more efficient for large uploads as no encoding takes place, but the server application must support parsing multi-part forms. Web Connection automatically handles this via Request.Form().

Example

loHTTP = CREATEOBJECT("wwHTTP") loHTTP.AddPostKey("Company","West Wind") loHTTP.AddPostKey("Name","Rick Strahl") lcHTML = loHTTP.HttpGet("http://www.west-wind.com/wconnect/testpage.wwd") *** Posting XML loHTTP.nHttpPostMode = 4 lcXML = FILETOSTR("someXmlData.xml") loHTTP.AddPostKey() && Clear POST buffer loHTTP.AddPostKey(lcXML) lcXML = loHTTP.HttpGet("http://www.west-wind.com/wconnect/testxml.wwd") *** Posting a multi-part form with a File Upload loHTTP.nHttpPostMode = 2 && Multipart form encoding loHTTP.AddPostKey() && Clear existing POST buffer *** Post a file and a regular form variable loHttp.AddPostKey("File","d:\temp\wws_invoice.pdf",.T.) loHttp.AddPostKey("txtFileNotes","test note") lcHTML = loHTTP.HTTPGet("http://localhost/wconnect/FileUpload.wwd")

See also:

Class wwipstuff | wwHTTP::nhttppostmode


  Last Updated: 11/7/2004 | © West Wind Technologies, 2008