netPut()
The function netPut() allows you to upload data to a server.
Synopsis
int netPut(string url, mapping|string|blob data [, mapping|string|blob &result]);
Parameter
Parameter | Description |
---|---|
url |
The URL (http, https, ftp and file - file only applies to local files). Since the URL has to correspond to specific syntax rules, the QT implementation of the URL parser tries to correct errors in the syntax. See the section "QUrl::TolerantMode" in the description Qt - QURL Parsing Mode and Uniform Resource Identifier (URI)- Generic Syntax. The function is terminated in case of an invalid URL and it returns -1. |
data |
The parameter "data" contains the data that is sent to server. The parameter can be a mapping, a string or a blob. Thus, 3 parameter types can be used. If a mapping is used as data, the keys described in the following can be used. A netPut request receives an answer from the server (HTTP protocol). The content of the answer can be passed in memory to the result mapping (see the description on the next row of this table) or you can you specify a target file via the "target" key in the data mapping. See the keys for the data mapping below.
|
result |
The function netPut receives an answer from the server and passes it the to result variable. Thereby the following keys are optionally set. The keys with the text (always) are always set. See https://tools.ietf.org/html/rfc2616#section-6.1.1.
|
Return value
The function returns 0 if it was successfully executed and in case of errors -1.
Description
The function netPut() allows uploading data to a server. The parameter "data" contains the data to be transmitted. The "data" parameter can be a mapping, a string or a blob. Thus, 3 parameter types can be used. If a mapping is used as data, keys described in the table above under "data" parameter are used.
/* The function netPut allows uploading data to a server.
IgnoreSslErros is used and since and empty string is passed, all SSL errors are ignored. */
main()
{
mapping m;
DebugN(netPut("http://localhost:80", makeMapping("content", "data to send", "followRedirection", false, "ignoreSslErrors", ""), m), m);
}
Assignment
HTTP functions
Availability
UI, CTRL