View Raw SPL
/*****************************************************************************
* *
* PUTURL.SPL Copyright (C) 2020 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Puts data to a URL *
* *
* Revisions: 20 Aug 2020 RRR Creation *
* *
*****************************************************************************/
#if @HELP_PUTURL
PUTURL
Purpose: Puts data to a URL.
Syntax: PUTURL("url", "data", "header", "typestr", "cmdtype", bufsize)
(result, status, errmes) = PUTURL("url", "data", "header", "typestr", "cmdtype", bufsize)
"url" - A string, the URL string.
"data" - A string, the data string. Defaults to empty,
no data.
"header" - A string, the HTML header string. Defaults to
"Content-Type: application/x-www-form-urlencoded\r\nAccept: */*\r\n"
"typestr" - A string. The returned data type:
"text": return a string (default)
"binary": return a binary series
"cmdtype" - A string. The HTML command. Defaults to "PUT".
bufsize - An integer. The initial size of the HTML transfer
buffer. Defaults to 65536.
Returns: A string or series, the result of the HTML request.
(result, status, errmes) = PUTURL("url", "data", "header", "typestr", "cmdtype", bufsize)
returns the value, integer status and error string.
Example:
url = "https://jsonplaceholder.typicode.com/posts/1";
hed = "Content-type: application/json; charset=UTF-8" + strescape("\r\n");
str = '{"id":1, "title":"A Title", "body":"A Body", "userId":200}';
jstr = puturl(url, str, hed);
Updates a simulated JSON store with the JSON object represented
by STR. To convert the returned JSON string to an object, use:
jobj = objjson(jstr);
Remarks:
PUTURL sends data to a URL as specified by "HEADER", "TYPESTR" and "CMDTYPE".
The result is buffered. The initial buffer size is doubled
until it fits the result.
PUTURL is a low level routine for HTML data transfers.
See Also:
Geturl
Objjson
Viewhtml
Viewjson
Webreadhtml
Webreadjson
Webreadimage
#endif
/* implemented as PUTURL.DLL */