The function sends an HTTP request to a specified server. The function has two versions:
1. Sending simple requests of type "key=value" using the header Content-Type: application/x-www-form-urlencoded.
2. Sending a request of any type specifying the custom set of headers for a more flexible interaction with various Web services.
[in] HTTP method.
[in] Request headers of type "key: value", separated by a line break "\r\n".
[in] Cookie value.
[in] Value of the Referer header of the HTTP request.
[in] Timeout in milliseconds.
[in] Data array of the HTTP message body.
[in] Size of the data array.
[out] An array containing server response data.
[out] Server response headers.
HTTP server response code or -1 for an error.
To use the WebRequest() function, add the addresses of the required servers in the list of allowed URLs in the "Expert Advisors" tab of the "Options" window. Server port is automatically selected on the basis of the specified protocol - 80 for "http://" and 443 for "https://".
The WebRequest() function is synchronous, which means its breaks the program execution and waits for the response from the requested server. Since the delays in receiving a response can be large, the function is not available for calls from indicators, because indicators run in a common thread shared by all indicators and charts on one symbol. Indicator performance delay on one of the charts of a symbol may stop updating of all charts of the same symbol.
The function can be called only from Expert Advisors and scripts, as they run in their own execution threads. If you try to call the function from an indicator, GetLastError() will return error 4014 – "Function is not allowed for call".
WebRequest() cannot be executed in the Strategy Tester.