Changeset 490 for trunk/zoo-project/zoo-kernel/zoo_loader.c
- Timestamp:
- Jun 27, 2014, 1:14:39 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/zoo_loader.c
r465 r490 54 54 55 55 xmlXPathObjectPtr extractFromDoc(xmlDocPtr,const char*); 56 int runRequest(map* );56 int runRequest(map**); 57 57 58 58 using namespace std; … … 91 91 if(strncmp(cgiContentType,"text/xml",8)==0 || 92 92 strncasecmp(cgiRequestMethod,"post",4)==0){ 93 if(cgiContentLength==NULL){ 94 cgiContentLength=0; 93 if(cgiContentLength==0){ 95 94 char *buffer=new char[2]; 96 95 char *res=NULL; 97 96 int r=0; 98 97 while((r=fread(buffer,sizeof(char),1,cgiIn))){ 98 buffer[1]=0; 99 99 cgiContentLength+=r; 100 100 if(res==NULL){ 101 res=(char*)malloc( 1*sizeof(char));101 res=(char*)malloc(2*sizeof(char)); 102 102 sprintf(res,"%s",buffer); 103 103 } 104 104 else{ 105 res=(char*)realloc(res,(cgiContentLength+1)*sizeof(char));106 105 char *tmp=zStrdup(res); 106 res=(char*)realloc(res,(strlen(tmp)+2)*sizeof(char)); 107 107 sprintf(res,"%s%s",tmp,buffer); 108 108 free(tmp); 109 109 } 110 110 } 111 delete[] buffer; 111 112 if(res==NULL && (strQuery==NULL || strlen(strQuery)==0)){ 112 113 return errorException(NULL,"ZOO-Kernel failed to process your request cause the request was emtpty.","InternalError",NULL); … … 114 115 if(strQuery==NULL || strlen(strQuery)==0) 115 116 tmpMap=createMap("request",res); 116 } 117 } 118 if(res!=NULL) 119 free(res); 117 120 }else{ 118 121 char *buffer=new char[cgiContentLength+1]; 119 if(fread(buffer,sizeof(char),cgiContentLength,cgiIn)> =0){122 if(fread(buffer,sizeof(char),cgiContentLength,cgiIn)>0){ 120 123 buffer[cgiContentLength]=0; 121 124 tmpMap=createMap("request",buffer); … … 146 149 arrayStep++; 147 150 } 148 tmpMap=createMap("request",buffer); 151 if(tmpMap!=NULL) 152 addToMap(tmpMap,"request",buffer); 153 else 154 tmpMap=createMap("request",buffer); 149 155 } 150 156 delete[]buffer; … … 202 208 #endif 203 209 ){ 204 /**205 * First include the MetaPath and the ServiceProvider default parameters206 * (which should be always available in GET params so in cgiQueryString)207 */208 char *str1;209 str1=cgiQueryString;210 210 /** 211 211 * Store the original XML request in xrequest map … … 232 232 } 233 233 } 234 xmlXPathFreeObject(reqptr); 234 235 } 235 236 } … … 239 240 tval=NULL; 240 241 tval = (char*) xmlGetProp(cur,BAD_CAST "service"); 241 if(tval!=NULL) 242 if(tval!=NULL){ 242 243 addToMap(tmpMap,"service",tval); 244 xmlFree(tval); 245 } 243 246 tval=NULL; 244 247 tval = (char*) xmlGetProp(cur,BAD_CAST "language"); 245 if(tval!=NULL) 248 if(tval!=NULL){ 246 249 addToMap(tmpMap,"language",tval); 250 xmlFree(tval); 251 } 247 252 const char* requests[3]={"GetCapabilities","DescribeProcess","Execute"}; 248 253 for(int j=0;j<3;j++){ … … 256 261 #endif 257 262 if(req!=NULL && req->nodeNr==1){ 263 if(t1->value!=NULL) 264 free(t1->value); 258 265 t1->value=zStrdup(requests[j]); 259 266 j=2; … … 272 279 tval=NULL; 273 280 tval = (char*) xmlGetProp(cur,BAD_CAST "version"); 274 if(tval!=NULL) 281 if(tval!=NULL){ 275 282 addToMap(tmpMap,"version",tval); 283 xmlFree(tval); 284 } 276 285 tval = (char*) xmlGetProp(cur,BAD_CAST "language"); 277 if(tval!=NULL) 286 if(tval!=NULL){ 278 287 addToMap(tmpMap,"language",tval); 288 xmlFree(tval); 289 } 279 290 xmlXPathObjectPtr idptr=extractFromDoc(doc,"/*/*[local-name()='Identifier']"); 280 291 if(idptr!=NULL){ … … 343 354 if(strQuery!=NULL) 344 355 free(strQuery); 345 runRequest(tmpMap); 356 357 runRequest(&tmpMap); 346 358 347 359 /** 348 360 * Required but can't be made after executing a process using POST requests. 349 361 */ 350 if( strncasecmp(cgiRequestMethod,"post",4)!=0 && count(tmpMap)!=1 &&tmpMap!=NULL){362 if(/*strncasecmp(cgiRequestMethod,"post",4)!=0 && count(tmpMap)!=1 && */tmpMap!=NULL){ 351 363 freeMap(&tmpMap); 352 364 free(tmpMap);
Note: See TracChangeset
for help on using the changeset viewer.