WebUrlPutBin Function

Action

Sends binary data to the Web server by means of the HTTP PUT method. Instead of ASCII-encoded content, binary data may be sent using this function. The Content-Length header will automatically be added to the request. The appropriate Content-Type has to be specified. In order to send binary data (octets) more safely over the Internet, use the WebBase64Encode to convert the data to 6-bit ASCII characters.

Include file

WebAPI.bdh

Syntax

WebUrlPutBin( in sUrl     : string,
              in sData    : string,
              in nDataLen : number,
              in sContent : string,
              in fWait    : float optional): boolean;

Return value

  • true if the worker thread posting the form content to the server could be started successfully

  • false otherwise

Parameter Description
sUrl Complete URL to the file on the server
sData Data to post to the server. This may be also binary data. For posting all available binary data specify STRING_COMPLETE for nDataLength and use the bin() operator for sData (see example).
nDataLen Length in bytes of data contained in the buffer sData. Specify STRING_COMPLETE or omit this parameter to post all available data.
sContent Content type string used in the request, for example "image/gif"
fWait Minimum time or minimum mean time that this function call has to last (optional). Default value is 0.0

Example

dcltrans
  transaction TWebHttp11
   var
    sData : string;
  begin
    WebUrlTrace("http://standardhost/index.html", 0.0);
    // To have a resource we can delete, we first have to
    // upload a test file to the server.
    // Note that you will need write permissions
    WebUrlPutBin("http://standardhost/test.html",
      "1234567890", STRING_COMPLETE, "text/txt", 0.0);
    sData := "\h00010203040506070809101112131415";
    WebUrlPutBin("http://standardhost/test.html",
                 bin(sData), STRING_COMPLETE, "application/octet-stream", 0.0);
    // And now let’s delete it again.
    WebUrlDelete("http://standardhost/test.html", 0.0);
    WebUrlOptions("http://standardhost/*", 0.0);
  end TWebHttp11;

Sample scripts

WebHttp11.bdf