Bug in WebRequest function - MT5 build 1881

 

Hello,

The objective of this topic is to communicate a bug to MetaQuotes, I sent it to tickets system, but there is no tickets system anymore. :-(

Some releases behind MT5 came with some bugs in the WebRequest function and aparently the problems were solved, but, I got a new one in the release 1881.

When the WebRequest function sends a request, it gets a return code and the answer in the "result" array, so, in a normal situation the return code is 200 and the array "result" is the status of the operation.


These are the parameters of the WebRequest function:

int  WebRequest(
   const string      method,           // HTTP method 
   const string      url,              // URL
   const string      cookie,           // cookie
   const string      referer,          // referer
   int               timeout,          // timeout
   const char        &data[],          // the array of the HTTP message body
   int               data_size,        // data[] array size in bytes
   char              &result[],        // an array containing server response data
   string            &result_headers   // headers of server response
   );


The problem:

In my EA the WebRequest function sends some data to my server and the server returns a string with the status of the operation and the code 201, that, according to W3C, 201 is the code to new data created (https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html). So, WebRequest function gets the code 201, clear the "result" array and set the "_LastError" variable to 5203 (HTTP request failed).

 * First big deal: the "result" array should never be cleared, with or without an error. This array can have infomations about the error.

 * Second big deal: returning a code different than 200 doesn't meaning an error. See the definitions in W3C site.

 * Third deal: the string "result_headers" also have no content, it is NULL;


Sorry to not sharing any code, it is confidential.

Reason: