httpGet: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(No difference)
|
Revision as of 17:41, 24 October 2020
Function
Server Only
Online and Offline
Available since Server 1.0.0
void httpGet(string url, string postData, function dataReceivedCallback, function completedCallback)
The httpGet function is used to perform a HTTP transfer asynchronously.
postData
is a blank string, then the GET request method is used, otherwise the POST request method is used.Parameters
1) | string | url | The URL to send the HTTP request to. |
2) | string | postData | The data to send as the body of the HTTP request. |
3) | function | dataReceivedCallback | The scripting function to call when data is read from the connection. This can be called multiple times. |
4) | function | completedCallback | The scripting function to call when data has been entirely read on the connection. |
Return
void | This function doesn't return a value. |
Callbacks
function dataReceivedCallback(ArrayBuffer receivedData)
This callback function can be called multiple times, or just once.
1) | ArrayBuffer | receivedData | The data received, which could be all of the data or just 1 byte. |
function completedCallback(int curlErrorCode, int httpResponseCode)
1) | int | curlErrorCode | The CURL error code. 0 means success. CURL Error Codes. |
2) | int | httpResponseCode | The HTTP response code. HTTP Response Codes. |
Notes
There aren't any notes for this function.
Examples
There aren't any examples for this function.
Compatibility
- In server version 1.1.22 and before, there was an issue where the connection would close after the dataReceivedCallback callback was called first time and did not return the received data length.
- In server version 1.1.22 and before, there was also an issue where the POST request method was used if the postData parameter was a blank string.
- In previous server versions, the dataReceivedCallback callback was invoked with a string parameter instead of an ArrayBuffer parameter.
Related
Server Related
httpGet