Ignore:
Timestamp:
Feb 18, 2015, 1:31:59 PM (9 years ago)
Author:
knut
Message:

Implemented asynchronous HTTP POST Execute requests on Windows platform (via caching). Fixed bug that caused only the last output variable in a HTTP POST Execute request to be returned. Modified the addToCache function so that the path of the cached file can be retrieved. Changed the parsing of KVPs in zoo_loader.c so that keys with missing values (e.g. "metapath=") are assigned the empty string instead of NULL (avoids segmentation fault in some situations). Added conditional definition of ZEND_DEBUG in service_internal_php.c. Deallocation of memory in function createProcess. In zoo_loader.c, applied url_decode to CGI form string (WIN32 only, but should check if this should apply to other platforms as well).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/zoo_service_loader.c

    r584 r587  
    751751
    752752  map *tmpReq = getMap (request_inputs, "xrequest");
    753   if (r_inputs2 != NULL)
     753 
     754  if(r_inputs2 != NULL && tmpReq != NULL) {
     755        const char key[] = "rfile=";
     756        char* kvp = (char*) malloc((FILENAME_MAX + strlen(key))*sizeof(char));
     757        char* filepath = kvp + strlen(key);
     758        strncpy(kvp, key, strlen(key));
     759        addToCache(m, tmpReq->value, tmpReq->value, "text/xml", strlen(tmpReq->value),
     760                   filepath, FILENAME_MAX);                               
     761    if (filepath == NULL) {
     762        errorException( m, _("Unable to cache HTTP POST Execute request."), "InternalError", NULL); 
     763                return;
     764    }   
     765        sprintf(tmp,"\"metapath=%s&%s&cgiSid=%s",
     766                r_inputs1->value,kvp,sid->value);
     767    sprintf(tmpq,"metapath=%s&%s",
     768                r_inputs1->value,kvp);
     769        free(kvp);             
     770  }
     771  else if (r_inputs2 != NULL)
    754772    {
    755773      sprintf (tmp,
    756                "\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s\"",
     774               "\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s",
    757775               r_inputs1->value, req->value, id->value, dataInputsKVP,
    758776               r_inputs2->name, dataOutputsKVP, sid->value);
     
    760778               "metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s",
    761779               r_inputs1->value, req->value, id->value, dataInputsKVP,
    762                r_inputs2->name, dataOutputsKVP);
     780               r_inputs2->name, dataOutputsKVP);                   
    763781    }
    764782  else
    765783    {
    766784      sprintf (tmp,
    767                "\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s\"",
     785               "\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s",
    768786               r_inputs1->value, req->value, id->value, dataInputsKVP,
    769787               sid->value);
     
    771789               "metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s",
    772790               r_inputs1->value, req->value, id->value, dataInputsKVP,
    773                sid->value);
     791               sid->value);   
    774792    }
    775793
     
    780798    }
    781799  char *tmp1 = zStrdup (tmp);
    782   sprintf (tmp, "\"%s\" %s \"%s\"", PROGRAMNAME, tmp1, sid->value);
     800  sprintf (tmp, "\"%s\" %s \"%s\"", PROGRAMNAME, tmp1, sid->value); 
    783801  free (dataInputsKVP);
    784802  free (dataOutputsKVP);
     
    794812  SetEnvironmentVariable ("CGISID", TEXT (sid->value));
    795813  SetEnvironmentVariable ("QUERY_STRING", TEXT (tmpq));
     814  // knut: Prevent REQUEST_METHOD=POST in background process call to cgic:main (process hangs when reading cgiIn):
     815  SetEnvironmentVariable("REQUEST_METHOD", "GET");
     816 
    796817  char clen[1000];
    797818  sprintf (clen, "%d", strlen (tmpq));
     
    813834      fprintf (stderr, "CreateProcess failed (%d).\n", GetLastError ());
    814835#endif
     836      if (tmp != NULL) {
     837        free(tmp);
     838      }
     839      if (tmpq != NULL) {
     840        free(tmpq);
     841      }         
    815842      return;
    816843    }
     
    818845    {
    819846#ifdef DEBUG
    820       fprintf (stderr, "CreateProcess successfull (%d).\n\n\n\n",
     847      fprintf (stderr, "CreateProcess successful (%d).\n\n\n\n",
    821848               GetLastError ());
    822849#endif
     
    824851  CloseHandle (pi.hProcess);
    825852  CloseHandle (pi.hThread);
     853 
     854  if (tmp != NULL) {
     855    free(tmp);
     856  }
     857  if (tmpq != NULL) {
     858    free(tmpq);
     859  }
     860 
    826861#ifdef DEBUG
    827862  fprintf (stderr, "CreateProcess finished !\n");
     
    13671402                             "InternalError", NULL);
    13681403    }
     1404
    13691405  r_inputs = getMap (request_inputs, "MetaPath");
    13701406  if (r_inputs != NULL)
     
    28212857                    while (cur1 != NULL && cur1->type != XML_ELEMENT_NODE)
    28222858                      cur1 = cur1->next;
     2859                                 
     2860                                        if (request_output_real_format == NULL)
     2861                                          request_output_real_format = dupMaps (&tmpmaps);
     2862                                        else
     2863                                          addMapsToMaps (&request_output_real_format, tmpmaps);
    28232864                  }
    2824               }
    2825             if (request_output_real_format == NULL)
    2826               request_output_real_format = dupMaps (&tmpmaps);
    2827             else
    2828               addMapsToMaps (&request_output_real_format, tmpmaps);
    2829             if (tmpmaps != NULL)
    2830               {
    2831                 freeMaps (&tmpmaps);
    2832                 free (tmpmaps);
    2833                 tmpmaps = NULL;
    28342865              }
    28352866          }
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png