• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

Android http_get return 0 and the returned string have IOException as value

osamara

Member
hello all
I'm trying to find solution for this problem
i have http_get request to php page that will do some database job and return some info.

the code works fine on some devices
but on other devices it return 0; and
ds_map_find_value(async_load, "result"); have the value IOException

this is my code

GML:
if(global.enter_login_get==1)
{
if ds_map_find_value(async_load, "id") == get77
   {
      show_message_async(string(ds_map_find_value(async_load, "status")))
   if ds_map_find_value(async_load, "status") >= 0
      {
      r_str = ds_map_find_value(async_load, "result");
      show_message_async(r_str);
      if(r_str!="")
      {
                if(is_string(r_str))
      {
        d_map = json_decode(r_str);
        if(d_map != -1)
        {
        global.data_list_for_user = ds_map_find_value(d_map,"data");
        show_message_async(ds_map_find_value(d_map,"data"));
        //alarm[4] = 1;
        }
        else
        {
            
        }
      }
      }
      }
   else
      {
      r_str = "null";
      }
   }
global.enter_login_get = 0;
}
as i say it work fine on some devices and give this problem on others


any ideas why?
please i have a week struggling with this problem.
 

FrostyCat

Member
Check async_load[? "result"] only when async_load[? "status"] is exactly 0. For larger downloads, the HTTP event may fire several times with async_load[? "status"] set to 1 (for in-progress) where it does not have a result, before firing one final time with async_load[? "status"] set to 0 where it does have a result.

Part of the confusion dates from the GMS 1.x timeframe, when the behaviour silently changed from ">= 0 for success" to "0 for success and 1 for in-progress". This caught a lot of HTTP code off guard, and a number of tutorials didn't update to account for this. If you see async_load[? "status"] >= 0 in HTTP-dealing GML, it dates from GM:HTML5 or an early version of GMS 1.x, and is now unsafe. The current practice is to either check async_load[? "status"] == 0 explicitly, or handle the 1 and 0 cases separately.
 
Top