mt5 webrequest annoying bug

 

good luck finding it...

webrequest somehow adds "\u0000" to query parameters and it causes issues on some server.

A simple way to test, post anything to 

http://httpbin.org/anything


string SendRequest(string method, string url, string headers="", string params="", int timeout=5000)
{
      char data[];
      char result[];
      string resp_headers;
      ResetLastError();
      StringToCharArray(params, data);
      int res = WebRequest(method, url, headers, timeout, data, result, resp_headers);
      if (res != -1)
      {
         Print("*** Resp Headers");
         Print(resp_headers);
         Print("*** Resp");
         string resp = CharArrayToString(result);
         Print(resp);
         Print("*** Data");
         Print(CharArrayToString(data));
         return resp;
      }
      else
      {
         int err = GetLastError();
         PrintFormat("error: %d (%d)", res, err);
         Print(CharArrayToString(data));
      }
      return "";
}


void OnStart()
{
   string api_url = "http://httpbin.org/anything";
   string params = "name=USERNAME&anoy=ing_buggy_mt5";
   string headers = "Authorization: Basic test\r\n";
   headers += "Content-Type: application/x-www-form-urlencoded;charset=UTF-8\r\n";
   string resp = SendRequest("GET", api_url, headers, params);
}