Index: branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/request_parser.c
===================================================================
--- branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/request_parser.c	(revision 672)
+++ branches/PublicaMundi_David_integration_01-devel/zoo-project/zoo-kernel/request_parser.c	(revision 741)
@@ -92,5 +92,5 @@
 		       _("The maximum allowed occurrences for <%s> (%i) was exceeded."),
 		       mi->name, atoi (testMap->value));
-	      errorException (m, emsg, "InternalError", NULL);
+	      errorException (m, emsg, "InternalError", NULL,NULL);
 	      return -1;
 	    }
@@ -113,5 +113,5 @@
 			   ("ZOO-Kernel was unable to load your data for %s position %s."),
 			   mi->name, tmpMap->value);
-		  errorException (m, emsg, "InternalError", NULL);
+		  errorException (m, emsg, "InternalError", NULL,NULL);
 		  return -1;
 		}
@@ -124,5 +124,5 @@
 		       ("The maximum allowed occurrences for <%s> is one."),
 		       mi->name);
-	      errorException (m, emsg, "InternalError", NULL);
+	      errorException (m, emsg, "InternalError", NULL,NULL);
 	      return -1;
 	    }
@@ -213,5 +213,5 @@
 	free(cursor_input);
 	return errorException (*main_conf, _("Unable to allocate memory."),
-			       "InternalError", NULL);
+			       "InternalError", NULL,NULL);
       }
     int i = 0;
@@ -224,5 +224,5 @@
 	    free(cursor_input);
 	    return errorException (*main_conf, _("Unable to allocate memory."),
-				   "InternalError", NULL);
+				   "InternalError", NULL,NULL);
 	  }
 	snprintf (inputs_as_text[i], strlen (pToken) + 1, "%s", pToken);
@@ -261,5 +261,5 @@
 		    return errorException (*main_conf,
 					   _("Unable to allocate memory."),
-					   "InternalError", NULL);
+					   "InternalError", NULL,NULL);
 		  }
 		tmpmaps->name = zStrdup (tmpn);
@@ -316,15 +316,14 @@
 				 tmpv1 + 1);
 			free(cursor_input);
-			return errorException (*main_conf, emsg, "InternalError", NULL);
+			return errorException (*main_conf, emsg, "InternalError", NULL,NULL);
 		      }
 		    addToMap (tmpmaps->content, tmpn1, tmpx2);
-		    {
 		      if (loadRemoteFile
 			  (&*main_conf, &tmpmaps->content, hInternet, tmpx2) < 0)
 			{
 			  free(cursor_input);
-			  return errorException (*main_conf, "Unable to fetch any ressource", "InternalError", NULL);
+			  return errorException (*main_conf, "Unable to fetch any ressource", "InternalError", NULL,NULL);
 			}
-		      }
+		      
 		    free (tmpx2);
 		    addIntToMap (tmpmaps->content, "Order", hInternet->nb);
@@ -350,5 +349,5 @@
 			  {
 			    free(cursor_input);
-			    return errorException (*main_conf, "Unable to append maps", "InternalError", NULL);
+			    return errorException (*main_conf, "Unable to append maps", "InternalError", NULL,NULL);
 			  }
 		      }
@@ -402,5 +401,5 @@
 	  free(cursor_output);
 	  return errorException (*main_conf, _("Unable to allocate memory"),
-				 "InternalError", NULL);
+				 "InternalError", NULL,NULL);
 	}
       int i = 0;
@@ -413,5 +412,5 @@
 	      free(cursor_output);
 	      return errorException (*main_conf, _("Unable to allocate memory"),
-				     "InternalError", NULL);
+				     "InternalError", NULL,NULL);
 	    }
 	  snprintf (outputs_as_text[i], strlen (pToken) + 1, "%s",
@@ -440,5 +439,5 @@
 						 _
 						 ("Unable to allocate memory."),
-						 "InternalError", NULL);
+						 "InternalError", NULL,NULL);
 			}
 		      tmp_output->name = zStrdup (tmpc);
@@ -536,5 +535,5 @@
 						 _
 						 ("Unable to allocate memory."),
-						 "InternalError", NULL);
+						 "InternalError", NULL,NULL);
 			}
 		      tmpmaps->name = zStrdup ((char *) val);
@@ -561,5 +560,5 @@
 						 _
 						 ("Unable to allocate memory."),
-						 "InternalError", NULL);
+						 "InternalError", NULL,NULL);
 			}
 		      tmpmaps->name = zStrdup ("missingIndetifier");
@@ -613,5 +612,5 @@
 							     _("Unable to add a request in the queue."),
 							     "InternalError",
-							     NULL);
+							     NULL,NULL);
 				    }
 				  addIntToMap (tmpmaps->content, "Order", hInternet->nb);
@@ -665,5 +664,5 @@
 							     ("Unable to allocate memory."),
 							     "InternalError",
-							     NULL);
+							     NULL,NULL);
 				    }
 				  snprintf (has,
@@ -675,11 +674,12 @@
 			      xmlFree (val);
 			    }
-			  hInternet->ihandle[hInternet->nb].header = NULL;
-			  hInternet->ihandle[hInternet->nb].header =
-			    curl_slist_append (hInternet->ihandle
-					       [hInternet->nb].header,
-					       has);
-			  if (has != NULL)
-			    free (has);
+                if (has != NULL){
+                            hInternet->ihandle[hInternet->nb].header = NULL;
+                            hInternet->ihandle[hInternet->nb].header =
+                              curl_slist_append (hInternet->ihandle
+                                                 [hInternet->nb].header,
+                                                 has);
+                            free (has);
+                }
 			}
 		      else
@@ -781,5 +781,5 @@
 							   ("Unable to allocate memory."),
 							   "InternalError",
-							   NULL);
+							   NULL,NULL);
 				  }
 				size_t bRead;
@@ -951,5 +951,5 @@
 				  xmlDocDumpFormatMemoryEnc (doc1, &mv,
 							     &buffersize,
-							     "utf-8", 1);
+							     "utf-8", 0);
 				  char size[1024];
 				  sprintf (size, "%d", buffersize);
@@ -966,10 +966,7 @@
 				    xmlDocDumpFormatMemoryEnc (doc1, &mv,
 							       &buffersize,
-							       "utf-8", 1);
-				    char size[1024];
-				    sprintf (size, "%d", buffersize);
-				    addToMap (tmpmaps->content, "size",
-					      size);
-				    xmlFreeDoc (doc2);
+							       "utf-8", 0);
+				    addIntToMap(tmpmaps->content, "size",buffersize);
+                    xmlFreeDoc (doc2);
 				    xmlFreeDoc (doc1);
 				  }
@@ -1024,5 +1021,5 @@
 					       _("Unable to append maps to maps."),
 					       "InternalError",
-					       NULL);
+					       NULL,NULL);
 		      }
 		  }
@@ -1113,5 +1110,5 @@
 	    {
 	      return errorException (*main_conf, _("Unable to allocate memory."),
-				     "InternalError", NULL);
+				     "InternalError", NULL,NULL);
 	    }
 	  tmpmaps->name = zStrdup ("unknownIdentifier");
@@ -1205,5 +1202,5 @@
 				     _
 				     ("Unable to allocate memory."),
-				     "InternalError", NULL);
+				     "InternalError", NULL,NULL);
 	    }
 	    tmpmaps->name = zStrdup ("unknownIdentifier");
@@ -1292,5 +1289,5 @@
 				     _
 				     ("Duplicate <Output> elements in WPS Execute request"),
-				     "InternalError", NULL);
+				     "InternalError", NULL,NULL);
 	    }
 	    else {
@@ -1320,5 +1317,5 @@
  * @return 0 on success, -1 on failure
  */
-int xmlParseRequest(maps** main_conf,const char* post,map** request_inputs,service* s,maps** inputs,maps** outputs,HINTERNET* hInternet){
+int xmlParseRequest(maps** main_conf,const char* post,map** request_inputs,service* s,maps** inputs,maps** outputs,HINTERNET* hInternet,struct cgi_env *cgi){
 
   map* version=getMapFromMaps(*main_conf,"main","rversion");
@@ -1326,5 +1323,5 @@
 
   xmlInitParser ();
-  xmlDocPtr doc = xmlParseMemory (post, cgiContentLength);
+  xmlDocPtr doc = xmlParseMemory (post, cgi->cgiContentLength);
 
   /**
@@ -1428,5 +1425,5 @@
  * @see kvpParseOutputs,kvpParseInputs,xmlParseRequest
  */
-int parseRequest(maps** main_conf,map** request_inputs,service* s,maps** inputs,maps** outputs,HINTERNET* hInternet){
+int parseRequest(maps** main_conf,map** request_inputs,service* s,maps** inputs,maps** outputs,HINTERNET* hInternet,struct cgi_env *cgi){
   map *postRequest = NULL;
   postRequest = getMap (*request_inputs, "xrequest");
@@ -1443,5 +1440,5 @@
     {
       //Parse XML request
-      if(xmlParseRequest(main_conf,postRequest->value,request_inputs,s,inputs,outputs,hInternet)<0){
+      if(xmlParseRequest(main_conf,postRequest->value,request_inputs,s,inputs,outputs,hInternet,cgi)<0){
 	return -1;
       }
@@ -1465,9 +1462,13 @@
  * @see runHttpRequests
  */
-int validateRequest(maps** main_conf,service* s,map* original_request, maps** request_inputs,maps** request_outputs,HINTERNET* hInternet){
-
+int validateRequest(maps** main_conf,service* s,map* original_request, maps** request_inputs,maps** request_outputs,HINTERNET* hInternet,struct cgi_env * cgi){
+  fprintf(stderr,"STEP 1 VALIDATE \n");
+  
   runHttpRequests (main_conf, request_inputs, hInternet);
+fprintf(stderr,"STEP 2 VALIDATE \n");
+  
   InternetCloseHandle (hInternet);
-
+  fprintf(stderr,"STEP 3 VALIDATE \n");
+                
   map* errI=NULL;
   char *dfv = addDefaultValues (request_inputs, s->inputs, *main_conf, 0,&errI);
@@ -1491,5 +1492,5 @@
               addToMap (tmpe, "locator", ptr->name);
               addToMap (tmpe, "text", tmps);
-              printExceptionReportResponse (*main_conf, tmpe);
+              printExceptionReportResponse (*main_conf, tmpe,NULL);
               freeMap (&tmpe);
               free (tmpe);
@@ -1499,8 +1500,11 @@
       ptr = ptr->next;
     }
-
+fprintf(stderr,"STEP 4 VALIDATE \n");
+  dumpMaps(*request_outputs);
   map* errO=NULL;
   char *dfv1 =
     addDefaultValues (request_outputs, s->outputs, *main_conf, 1,&errO);
+    fprintf(stderr,"STEP 4 - 1 VALIDATE \n");
+  
   if (strcmp (dfv1, "") != 0 || strcmp (dfv, "") != 0)
     {
@@ -1526,4 +1530,6 @@
 	  }
 	}
+    fprintf(stderr,"STEP 4 - 2 VALIDATE \n");
+  
       if (strcmp (dfv1, "") != 0)
         {
@@ -1553,5 +1559,7 @@
 	  }
 	}
-      printExceptionReportResponse (*main_conf, tmpe);
+    fprintf(stderr,"STEP 4 - 3 VALIDATE \n");
+  
+      printExceptionReportResponse (*main_conf, tmpe,NULL);
       if(errI!=NULL){
 	freeMap(&errI);
@@ -1567,4 +1575,6 @@
     }
   maps *tmpReqI = *request_inputs;
+  fprintf(stderr,"STEP 5 VALIDATE \n");
+  
   while (tmpReqI != NULL)
     {
@@ -1572,5 +1582,5 @@
       if (getMap (tmpReqI->content, "isFile") != NULL)
         {
-          if (cgiFormFileName (tmpReqI->name, name, sizeof (name)) ==
+          if (cgiFormFileName (tmpReqI->name, name, sizeof (name),&cgi) ==
               cgiFormSuccess)
             {
@@ -1586,8 +1596,8 @@
               int got, t;
               map *path = getMapFromMaps (*main_conf, "main", "tmpPath");
-              cgiFormFileSize (tmpReqI->name, &size);
+              cgiFormFileSize (tmpReqI->name, &size,&cgi);
               cgiFormFileContentType (tmpReqI->name, contentType,
-                                      sizeof (contentType));
-              if (cgiFormFileOpen (tmpReqI->name, &file) == cgiFormSuccess)
+                                      sizeof (contentType),&cgi);
+              if (cgiFormFileOpen (tmpReqI->name, &file,&cgi) == cgiFormSuccess)
                 {
                   t = -1;
@@ -1643,5 +1653,6 @@
       tmpReqI = tmpReqI->next;
     }
-
+fprintf(stderr,"STEP FINAL VALIDATE \n");
+  
   ensureDecodedBase64 (request_inputs);
   return 1;
