HTTPputAddrRequest - cBaseHTTPTransfer
Performs an HTTP PUT request using sFilePath
Type: Function
Return Data Type: Integer
Parameters
| Parameter | Type | Description |
|---|---|---|
| sFilePath | string | path to perform the HTTP PUT |
| aData | address | memory address of the data to be posted |
| iDataLength | Integer | number of bytes to post |
| bDataIsFile | boolean | If False, the value of aData is sent as HTTP PUT body. If True, aData is interpreted as a filename, and the contents of that file are sent as the POST body instead of the actual value of aData. |
Syntax
Function HTTPputAddrRequest string sFilePath address aData Integer iDataLength boolean bDataIsFile Returns Integer
Call Example
Get HTTPputAddrRequest sFilePath aData iDataLength bDataIsFile to IntegerVariable
Description
The HTTPputAddrRequest function performs an HTTP PUT request using sFilePath. All headers previously added using AddHeader, if any, are also sent as part of the request.
The OnDataReceived event is triggered for any response sent by RemoteHost.
This function is provided to allow the posting of large amounts of data (i.e., not limited to the maximum length of a DataFlex string). If you do not need to post large amounts of data you can use the simpler string-based function HttpPutRequest.
Sample
The following sample posts an XML document that is passed as an XML node. Since the length could be quite long, we use HttpPutAddrRequest method to do the post.
Function PutXmlNode string sHost string sFilePath handle hoXmlNode returns Boolean
address aXmlNode aXml
integer iVoid iLen
boolean bOK
handle hoXml
// write XML data to memory heap pointed to by aXMLNode
Get paXml of hoXmlNode to aXmlNode
// we assume data from paXml is always zero terminated
Move (Length(aXmlNode)) to iLen
Set psRemoteHost to sHost
Get AddHeader "CONTENT-TYPE" "text/xml" to bOK
Get HttpPutAddrRequest sFilePath aXml iLen False to bOK
Move (Free(aXmlNode)) to iVoid // free memory
Function_Return bOk
End_Function
| Col 1 | Col 2 |
|---|---|
| Note: | Note that the cXmlHttpTransfer class already provides the above functionality for you. |
Return Value
Returns True if successful, and False otherwise