nikhilgupta10 / GridLAB-D

Other
1 stars 0 forks source link

#925 HTTP XML Request Format xml/object:property does not work, #2651

Closed nikhilgupta10 closed 7 years ago

nikhilgupta10 commented 7 years ago

The specification for HTTP requests for XML in the format: http://server:port/xml/object:property does not work. It thinks that the object:property string is a global.

In core\server.c, the arguments for an xml request are split on /:

int nargs = sscanf(uri,\%1023[^/=\r\n]/%1023[^\r\n=]\,arg1,arg2);

Where uri is the request string (e.g., /xml/network_node:voltage_A, uri=network_node:voltage_A. If there is no slash separator in the request, then GridLAB-D assumes it is a global variable (i.e., nargs=1):

/* process request */
switch (nargs) {

/* get global variable */
case 1: 

    /* find the variable */
    if (global_getvar(arg1,buffer,sizeof(buffer))==NULL)
    {
        output_error(\global variable '%s' not found\, arg1);
        return 0;
    }

The code to split by : is never run and it returns an error.

/* get object property */
case 2:

    /* find the object */
    id = strchr(arg1,':');
    if ( id==NULL )
        obj = object_find_name(arg1);
    else
        obj = object_find_by_id(atoi(id+1));

Even if it does run, it looks like it tries to convert the property string from object:property into an integer ID to access the object instead of the name (e.g., network_node). The deprecated message does not have any impact on the behavior of the program (it executes after the object is read/write).

Test output that verifies my analysis:

nikhilgupta10 commented 7 years ago

nikhilgupta10 imported these comments from Sourceforge: The user dchassin does not exist anymore. Therefore assigning this to afisher1. "jcfuller":- status: new --> assigned