Ignore:
Timestamp:
Aug 5, 2011, 3:02:43 PM (13 years ago)
Author:
djay
Message:

Merge branch-1.2 r268:r296.

Location:
branches/branch-1.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/branch-1.2

  • branches/branch-1.2/zoo-kernel/zoo_loader.c

    r217 r301  
    4848}
    4949
     50#include "service_internal.h"
     51
    5052xmlXPathObjectPtr extractFromDoc(xmlDocPtr,const char*);
    5153int runRequest(map*);
    5254
    5355using namespace std;
    54 
    55 /* ************************************************************************* */
    56 
    57 int errorException(maps *m, const char *message, const char *errorcode)
    58 {
    59   map* errormap = createMap("text", message);
    60   addToMap(errormap,"code", errorcode);
    61   printExceptionReportResponse(m,errormap);
    62   freeMap(&errormap);
    63   free(errormap);
    64   return -1;
    65 }
    66 
    67 /* ************************************************************************* */
    68 
    6956
    7057#define TRUE 1
     
    8572#ifdef DEBUG
    8673  fprintf (stderr, "Addr:%s\n", cgiRemoteAddr);
    87   fprintf (stderr, "RequestMethod:%s\n", cgiRequestMethod);
     74  fprintf (stderr, "RequestMethod: (%s) %d %d\n", cgiRequestMethod,strncasecmp(cgiRequestMethod,"post",4),strncmp(cgiContentType,"text/xml",8)==0 || strncasecmp(cgiRequestMethod,"post",4)==0);
    8875  fprintf (stderr, "Request: %s\n", cgiQueryString);
    8976#endif
     
    9380  if(strncmp(cgiContentType,"text/xml",8)==0 ||
    9481     strncasecmp(cgiRequestMethod,"post",4)==0){
    95     char *buffer=new char[cgiContentLength+1];
    96     if(fread(buffer,1,cgiContentLength,cgiIn)){
    97       buffer[cgiContentLength]=0;
    98       tmpMap=createMap("request",buffer);
     82    if(cgiContentLength==NULL){
     83       cgiContentLength=0;
     84       char *buffer=new char[2];
     85       char *res=NULL;
     86       int r=0;
     87       while(r=fread(buffer,sizeof(char),1,cgiIn)){
     88         cgiContentLength+=r;
     89         if(res==NULL){
     90           res=(char*)malloc(1*sizeof(char));
     91           sprintf(res,"%s",buffer);
     92         }
     93         else{
     94           res=(char*)realloc(res,(cgiContentLength+1)*sizeof(char));
     95           char *tmp=strdup(res);
     96           sprintf(res,"%s%s",tmp,buffer);
     97           free(tmp);
     98         }
     99       }
     100       if(res==NULL){
     101         return errorException(NULL,"ZOO-Kernel failed to process your request cause the request was emtpty.","InternalError");
     102       }else
     103         tmpMap=createMap("request",res);
    99104    }else{
    100       char **array, **arrayStep;
    101       if (cgiFormEntries(&array) != cgiFormSuccess) {
    102         return 1;
    103       }
    104       arrayStep = array;
    105       while (*arrayStep) {
    106         char *value=new char[cgiContentLength];
    107         cgiFormStringNoNewlines(*arrayStep, value, cgiContentLength);
    108         char* tmpValueFinal=(char*) malloc((strlen(*arrayStep)+strlen(value)+1)*sizeof(char));
    109         sprintf(tmpValueFinal,"%s=%s",*arrayStep,value);
    110         tmpMap=createMap("request",tmpValueFinal);
    111         free(tmpValueFinal);
    112 #ifdef DEBUG
    113         fprintf(stderr,"(( \n %s \n %s \n ))",*arrayStep,value);
    114 #endif
    115         delete[]value;
    116         arrayStep++;
    117       }
    118     }
    119     delete[]buffer;
     105      char *buffer=new char[cgiContentLength+1];
     106      if(fread(buffer,sizeof(char),cgiContentLength,cgiIn)){
     107        buffer[cgiContentLength]=0;
     108        tmpMap=createMap("request",buffer);
     109      }else{
     110        buffer[0]=0;
     111        char **array, **arrayStep;
     112        if (cgiFormEntries(&array) != cgiFormSuccess) {
     113          return 1;
     114        }
     115        arrayStep = array;
     116        while (*arrayStep) {
     117          char *ivalue=new char[cgiContentLength];
     118          cgiFormStringNoNewlines(*arrayStep, ivalue, cgiContentLength);
     119          char* tmpValueFinal=(char*) malloc((strlen(*arrayStep)+strlen(ivalue)+1)*sizeof(char));
     120          sprintf(tmpValueFinal,"%s=%s",*arrayStep,ivalue);
     121          if(strlen(buffer)==0){
     122            sprintf(buffer,"%s",tmpValueFinal);
     123          }else{
     124            char *tmp=strdup(buffer);
     125            sprintf(buffer,"%s&%s",tmp,tmpValueFinal);
     126            free(tmp);
     127          }
     128         
     129          sprintf(tmpValueFinal,"%s=%s",*arrayStep,ivalue);
     130          free(tmpValueFinal);
     131#ifdef DEBUG
     132          fprintf(stderr,"(( \n %s \n %s \n ))",*arrayStep,ivalue);
     133#endif
     134          delete[]ivalue;
     135          arrayStep++;
     136        }
     137        tmpMap=createMap("request",buffer);
     138      }
     139      delete[]buffer;
     140    }
    120141  }
    121142  else{
     
    162183      xmlInitParser();
    163184      xmlDocPtr doc = xmlParseMemory(t1->value,cgiContentLength);
     185
     186
     187      {
     188        xmlXPathObjectPtr reqptr=extractFromDoc(doc,"/*[local-name()='Envelope']/*[local-name()='Body']/*");
     189        if(reqptr!=NULL){
     190          xmlNodeSet* req=reqptr->nodesetval;
     191          if(req!=NULL && req->nodeNr==1){
     192            addToMap(tmpMap,"soap","true");
     193            int k=0;
     194            for(k;k < req->nodeNr;k++){
     195              xmlNsPtr ns=xmlNewNs(req->nodeTab[k],BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi");
     196              xmlDocSetRootElement(doc, req->nodeTab[k]);
     197              xmlChar *xmlbuff;
     198              int buffersize;
     199              xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, "utf-8", 1);
     200              addToMap(tmpMap,"xrequest",(char*)xmlbuff);
     201              char *tmp=(char*)xmlbuff;
     202              fprintf(stderr,"%s\n",tmp);
     203              xmlFree(xmlbuff);
     204            }
     205          }
     206        }
     207      }
     208
    164209      xmlNodePtr cur = xmlDocGetRootElement(doc);
    165210      char *tval;
     
    172217      if(tval!=NULL)
    173218        addToMap(tmpMap,"language",tval);
    174      
    175       const char* requests[3];
    176       requests[0]="GetCapabilities";
    177       requests[1]="DescribeProcess";
    178       requests[2]="Execute";
     219      const char* requests[3]={"GetCapabilities","DescribeProcess","Execute"};
    179220      for(int j=0;j<3;j++){
    180         char tt[35];
     221        char tt[128];
    181222        sprintf(tt,"/*[local-name()='%s']",requests[j]);
    182223        xmlXPathObjectPtr reqptr=extractFromDoc(doc,tt);
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