Index: trunk/zoo-project/zoo-kernel/service_internal.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal.c	(revision 490)
+++ trunk/zoo-project/zoo-kernel/service_internal.c	(revision 492)
@@ -1871,4 +1871,6 @@
       if(testMap!=NULL){
 	HINTERNET hInternet;
+	char* tmpValue;
+	size_t dwRead;
 	hInternet=InternetOpen(
 #ifndef WIN32
@@ -1879,6 +1881,9 @@
 			       NULL,NULL, 0);
 	testMap=getMap(m->content,"Reference");
-	loadRemoteFile(&m,&m->content,hInternet,testMap->value);
-	InternetCloseHandle(hInternet);
+	loadRemoteFile(&m,&m->content,&hInternet,testMap->value);
+	processDownloads(&hInternet);
+	tmpValue=(char*)malloc((hInternet.ihandle[0].nDataLen+1)*sizeof(char));
+	InternetReadFile(hInternet.ihandle[0],(LPVOID)tmpValue,hInternet.ihandle[0].nDataLen,&dwRead);
+	InternetCloseHandle(&hInternet);
       }
 #endif
@@ -1963,5 +1968,8 @@
 	else
 #endif
-	  xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
+	  if(strcasecmp(tmp->name,"datatype")==0)
+	    xmlNewProp(nc3,BAD_CAST "mimeType",BAD_CAST "text/plain");
+	  else
+	    xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
       }
       tmp=tmp->next;
@@ -2872,5 +2880,5 @@
     fprintf(stderr,"MIMETYPE: %s\n",mimeType);
 #endif
-    fwrite(mimeType,1,strlen(mimeType),fo);
+    fwrite(mimeType,sizeof(char),strlen(mimeType),fo);
     fclose(fo);
 
@@ -2901,10 +2909,58 @@
 }
 
+int runHttpRequests(maps** m,maps** inputs,HINTERNET* hInternet){
+  if(hInternet->nb>0){
+    processDownloads(hInternet);
+    maps* content=*inputs;
+    map* tmp1;
+    int index=0;
+    while(content!=NULL){
+      if((tmp1=getMap(content->content,"href")) || 
+	 (tmp1=getMap(content->content,"xlink:href"))){
+	if(getMap(content->content,"isCached")==NULL){
+	  char* fcontent;
+	  char *mimeType=NULL;
+	  int fsize=0;
+
+	  fcontent=(char*)malloc((hInternet->ihandle[index].nDataLen+1)*sizeof(char));
+	  if(fcontent == NULL){
+	    return errorException(*m, _("Unable to allocate memory."), "InternalError",NULL);
+	  }
+	  size_t dwRead;
+	  InternetReadFile(hInternet->ihandle[index], 
+			   (LPVOID)fcontent, 
+			   hInternet->ihandle[index].nDataLen, 
+			   &dwRead);
+	  fcontent[hInternet->ihandle[index].nDataLen]=0;
+	  fsize=hInternet->ihandle[index].nDataLen;
+	  mimeType=strdup((char*)hInternet->ihandle[index].mimeType);
+	  
+	  map* tmpMap=getMapOrFill(&content->content,"value","");
+	  free(tmpMap->value);
+	  tmpMap->value=(char*)malloc((fsize+1)*sizeof(char));
+	  if(tmpMap->value==NULL){
+	    return errorException(*m, _("Unable to allocate memory."), "InternalError",NULL);
+	  }
+	  memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char));
+	  
+	  char ltmp1[256];
+	  sprintf(ltmp1,"%d",fsize);
+	  addToMap(content->content,"size",ltmp1);
+	  addToCache(*m,tmp1->value,fcontent,mimeType,fsize);
+	  free(fcontent);
+	  free(mimeType);
+	}
+	index++;
+      }
+      content=content->next;
+    }
+  }
+}
+
 /**
  * loadRemoteFile:
  * Try to load file from cache or download a remote file if not in cache
  */
-int loadRemoteFile(maps** m,map** content,HINTERNET hInternet,char *url){
-  HINTERNET res;
+int loadRemoteFile(maps** m,map** content,HINTERNET* hInternet,char *url){
   char* fcontent;
   char* cached=isInCache(*m,url);
@@ -2932,19 +2988,11 @@
     }
   }else{
-    res=InternetOpenUrl(hInternet,url,NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0);
-    fcontent=(char*)malloc((res.nDataLen+1)*sizeof(char));
-    if(fcontent == NULL){
-      return errorException(*m, _("Unable to allocate memory."), "InternalError",NULL);
-    }
-    size_t dwRead;
-    InternetReadFile(res, (LPVOID)fcontent, res.nDataLen, &dwRead);
-    fcontent[res.nDataLen]=0;
-    fsize=res.nDataLen;
-    mimeType=(char*)res.mimeType;
+    hInternet->waitingRequests[hInternet->nb]=strdup(url);
+    InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0);
+    return 0;
   }
   if(fsize==0){
     return errorException(*m, _("Unable to download the file."), "InternalError",NULL);
   }
-
   if(mimeType!=NULL){
     addToMap(*content,"fmimeType",mimeType);
@@ -2957,5 +3005,4 @@
   if(tmpMap->value==NULL)
     return errorException(*m, _("Unable to allocate memory."), "InternalError",NULL);
-  //snprintf(tmpMap->value,(fsize+1)*sizeof(char),fcontent);
   memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char));
   
@@ -2965,4 +3012,6 @@
   if(cached==NULL)
     addToCache(*m,url,fcontent,mimeType,fsize);
+  else
+    addToMap(*content,"isCached","true");
   free(fcontent);
   free(mimeType);
Index: trunk/zoo-project/zoo-kernel/service_internal.h
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal.h	(revision 490)
+++ trunk/zoo-project/zoo-kernel/service_internal.h	(revision 492)
@@ -148,5 +148,6 @@
   void addToCache(maps*,char*,char*,char*,int);
   char* isInCache(maps*,char*);
-  int loadRemoteFile(maps**,map**,HINTERNET,char*);
+  int runHttpRequests(maps**,maps**,HINTERNET*);
+  int loadRemoteFile(maps**,map**,HINTERNET*,char*);
 
   char *readVSIFile(maps*,const char*);
Index: trunk/zoo-project/zoo-kernel/service_internal_js.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_js.c	(revision 490)
+++ trunk/zoo-project/zoo-kernel/service_internal_js.c	(revision 492)
@@ -732,5 +732,5 @@
 }
 
-HINTERNET setHeader(HINTERNET handle,JSContext *cx,JSObject *header){
+HINTERNET setHeader(HINTERNET* handle,JSContext *cx,JSObject *header){
   jsuint length=0;
   jsint i=0;
@@ -747,5 +747,5 @@
     fprintf(stderr,"header is an array of %d elements\n",length);
 #endif
-    handle.header=NULL;
+    handle->ihandle[handle->nb].header=NULL;
     for(i=0;i<length;i++){
       jsval tmp;
@@ -753,8 +753,8 @@
       tmp1=JSValToChar(cx,&tmp);
 #ifdef ULINET_DEBUG
-      curl_easy_setopt(handle.handle,CURLOPT_VERBOSE,1);
+      curl_easy_setopt(handle->ihandle[handle->nb].handle,CURLOPT_VERBOSE,1);
       fprintf(stderr,"Element of array n° %d, value : %s\n",i,tmp1);
 #endif
-      handle.header=curl_slist_append(handle.header, tmp1);
+      handle->ihandle[handle->nb].header=curl_slist_append(handle->ihandle[handle->nb].header, tmp1);
       free(tmp1);
     }
@@ -763,5 +763,5 @@
     fprintf(stderr,"not an array !!!!!!!\n");
   }
-  return handle;
+  return *handle;
 }
 
@@ -804,4 +804,5 @@
     url=JSValToChar(cx,argv);
   }
+  hInternet.waitingRequests[hInternet.nb]=strdup(url);
   if(argc==4){
     char *body;
@@ -812,23 +813,27 @@
 #endif
     if(JS_IsArrayObject(cx,header))
-      res1=setHeader(hInternet,cx,header);
+      setHeader(&hInternet,cx,header);
 #ifdef ULINET_DEBUG
     fprintf(stderr,"BODY (%s)\n",body);
 #endif
-    res=InternetOpenUrl(res1,url,body,strlen(body),
-			INTERNET_FLAG_NO_CACHE_WRITE,0);    
+    InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],body,strlen(body),
+		    INTERNET_FLAG_NO_CACHE_WRITE,0);    
+    processDownloads(&hInternet);
     free(body);
   }else{
     if(argc==3){
       char *body=JSValToChar(cx,&argv[2]);
-      res=InternetOpenUrl(hInternet,url,body,strlen(body),
-			  INTERNET_FLAG_NO_CACHE_WRITE,0);
+      InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],body,strlen(body),
+		      INTERNET_FLAG_NO_CACHE_WRITE,0);
+      processDownloads(&hInternet);
       free(body);
-    }
-    res=InternetOpenUrl(hInternet,url,NULL,0,
-			INTERNET_FLAG_NO_CACHE_WRITE,0);
-  }
-  tmpValue=(char*)malloc((res.nDataLen+1)*sizeof(char));
-  InternetReadFile(res,(LPVOID)tmpValue,res.nDataLen,&dwRead);
+    }else{
+      InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],NULL,0,
+		      INTERNET_FLAG_NO_CACHE_WRITE,0);
+      processDownloads(&hInternet);
+    }
+  }
+  tmpValue=(char*)malloc((hInternet.ihandle[0].nDataLen+1)*sizeof(char));
+  InternetReadFile(hInternet.ihandle[0],(LPVOID)tmpValue,hInternet.ihandle[0].nDataLen,&dwRead);
 #ifdef ULINET_DEBUG
   fprintf(stderr,"content downloaded (%d) (%s) \n",dwRead,tmpValue);
@@ -846,8 +851,5 @@
   if(argc>=2)
     free(method);
-  if(argc==4 && res.header!=NULL){
-    curl_slist_free_all(res.header);
-  }
-  InternetCloseHandle(hInternet);
+  InternetCloseHandle(&hInternet);
   JS_MaybeGC(cx);
   return JS_TRUE;
Index: trunk/zoo-project/zoo-kernel/service_internal_ms.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_ms.c	(revision 490)
+++ trunk/zoo-project/zoo-kernel/service_internal_ms.c	(revision 492)
@@ -201,5 +201,5 @@
   }
   addToMap(tmpI->content,"Reference",webService_url);
-
+  free(webService_url);
 }
 
@@ -255,4 +255,5 @@
 	      addToMap(output->content,"crs_isGeographic","false");
 	  }
+	  free(proj4Str);
 	}
 	else{
@@ -392,4 +393,5 @@
   FILE* file = fopen(pszDataSource, "rb");
   FILE* fileZ = fopen(odsName, "wb");
+  free(odsName);
   fseek(file, 0, SEEK_END);
   unsigned long fileLen=ftell(file);
@@ -467,6 +469,7 @@
       i++;
     }
-
-  }
+  }
+  free(sdsName);
+  free(dsName);
 
   OGRDataSourceH poDS = NULL;
@@ -568,4 +571,5 @@
       OSRExportToWkt(srs,&wkt);
       setSrsInformations(output,m,myLayer,wkt);
+      free(wkt);
     }
     else{
@@ -937,4 +941,5 @@
   close(f);
   addToMap(outputs->content,"storage",pszDataSource);
+  free(pszDataSource);
 
   /*
@@ -1032,4 +1037,6 @@
     cursor=cursor->next;
   }
+  freeMap(&correspondance);
+  free(correspondance);
 
   /*
@@ -1090,4 +1097,6 @@
   sprintf(mapPath,"%s/%s_%s.map",tmp1->value,outputs->name,sid->value);
   msSaveMap(myMap,mapPath);
+  free(mapPath);
+  msGDALCleanup();
   msFreeMap(myMap);
 }
Index: trunk/zoo-project/zoo-kernel/ulinet.c
===================================================================
--- trunk/zoo-project/zoo-kernel/ulinet.c	(revision 490)
+++ trunk/zoo-project/zoo-kernel/ulinet.c	(revision 492)
@@ -30,13 +30,13 @@
 #include "ulinet.h"
 #include <assert.h>
-
+  
 size_t write_data_into(void *buffer, size_t size, size_t nmemb, void *data){
   size_t realsize = size * nmemb;
-  HINTERNET *psInternet;
+  _HINTERNET *psInternet;
   if(buffer==NULL){
     buffer=NULL;
     return -1;
   }
-  psInternet=(HINTERNET *)data;
+  psInternet=(_HINTERNET *)data;
   if(psInternet->pabyData){
     psInternet->pabyData=(unsigned char*)realloc(psInternet->pabyData,psInternet->nDataLen+realsize+1);
@@ -64,5 +64,5 @@
     char path[1024];
     char domain[1024];
-	char* tmp;
+    char* tmp;
     for(i=0;i<12;i++)
 #ifndef WIN32
@@ -163,63 +163,72 @@
 #endif
 
-HINTERNET InternetOpen(char* lpszAgent,int dwAccessType,char* lpszProxyName,char* lpszProxyBypass,int dwFlags){  
+HINTERNET InternetOpen(char* lpszAgent,int dwAccessType,char* lpszProxyName,char* lpszProxyBypass,int dwFlags){
   HINTERNET ret;
   ret.handle=curl_multi_init();
-  ret.ihandle=NULL;
-  ret.hasCacheFile=0;
-  ret.nDataAlloc = 0;
-  ret.mimeType = NULL;
   ret.agent=strdup(lpszAgent);
+  ret.nb=0;
+  ret.ihandle[ret.nb].header=NULL;
   return ret;
 }
 
-void InternetCloseHandle(HINTERNET handle){
-  if(handle.hasCacheFile>0){
-    fclose(handle.file);
-    unlink(handle.filename);
-    handle.mimeType = NULL;
-  }
-  else{
-    handle.pabyData = NULL;
-    handle.mimeType = NULL;
-    handle.nDataAlloc = handle.nDataLen = 0;
-  }
-  if(handle.ihandle!=NULL)
-    curl_easy_cleanup(handle.ihandle);
-  if(handle.handle)
-    curl_multi_cleanup(handle.handle);
-  free(handle.agent);
-}
-
-HINTERNET InternetOpenUrl(HINTERNET hInternet,LPCTSTR lpszUrl,LPCTSTR lpszHeaders,size_t dwHeadersLength,size_t dwFlags,size_t dwContext){
+void InternetCloseHandle(HINTERNET* handle0){
+  int i=0;
+  for(i=0;i<handle0->nb;i++){
+    _HINTERNET handle=handle0->ihandle[i];
+    if(handle.hasCacheFile>0){
+      fclose(handle.file);
+      unlink(handle.filename);
+      handle.mimeType = NULL;
+    }
+    else{
+      handle.pabyData = NULL;
+      handle.mimeType = NULL;
+      handle.nDataAlloc = handle.nDataLen = 0;
+    }
+    if(handle0->ihandle[i].header!=NULL){
+      curl_slist_free_all(handle0->ihandle[i].header);
+      handle0->ihandle[i].header=NULL;
+    }
+    free(handle.mimeType);
+  }
+  if(handle0->handle)
+    curl_multi_cleanup(handle0->handle);
+  free(handle0->agent);
+  for(i=handle0->nb-1;i>=0;i--){
+    free(handle0->waitingRequests[i]);
+  }
+}
+
+HINTERNET InternetOpenUrl(HINTERNET* hInternet,LPCTSTR lpszUrl,LPCTSTR lpszHeaders,size_t dwHeadersLength,size_t dwFlags,size_t dwContext){
 
   char filename[255];
   struct MemoryStruct header;
 
-  hInternet.nDataLen = 0;
-
-  hInternet.nDataAlloc = 0;
-  hInternet.pabyData= NULL;
-
-  if(hInternet.ihandle!=NULL)
-    curl_easy_cleanup(hInternet.ihandle);
-  hInternet.ihandle=curl_easy_init( );
-  curl_easy_setopt(hInternet.ihandle, CURLOPT_COOKIEFILE, "ALL");
+  hInternet->ihandle[hInternet->nb].handle=curl_easy_init( );
+  hInternet->ihandle[hInternet->nb].hasCacheFile=0;
+  hInternet->ihandle[hInternet->nb].nDataAlloc = 0;
+  hInternet->ihandle[hInternet->nb].mimeType = NULL;
+  hInternet->ihandle[hInternet->nb].nDataLen = 0;
+  hInternet->ihandle[hInternet->nb].id = hInternet->nb;
+  hInternet->ihandle[hInternet->nb].nDataAlloc = 0;
+  hInternet->ihandle[hInternet->nb].pabyData = NULL;
+
+  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_COOKIEFILE, "ALL");
 #ifndef TIGER
-  curl_easy_setopt(hInternet.ihandle, CURLOPT_COOKIELIST, "ALL");
-#endif
-  curl_easy_setopt(hInternet.ihandle, CURLOPT_USERAGENT, hInternet.agent);
-  
-  curl_easy_setopt(hInternet.ihandle,CURLOPT_FOLLOWLOCATION,1);
-  curl_easy_setopt(hInternet.ihandle,CURLOPT_MAXREDIRS,3);
+  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_COOKIELIST, "ALL");
+#endif
+  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_USERAGENT, hInternet->agent);
+  
+  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_FOLLOWLOCATION,1);
+  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_MAXREDIRS,3);
   
   header.memory=NULL;
   header.size = 0;
 
-  curl_easy_setopt(hInternet.ihandle, CURLOPT_HEADERFUNCTION, header_write_data);
-  curl_easy_setopt(hInternet.ihandle, CURLOPT_WRITEHEADER, (void *)&header);
-
-#ifdef MSG_LAF_VERBOSE
-  curl_easy_setopt(hInternet.ihandle, CURLOPT_VERBOSE, 1);
+  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_HEADERFUNCTION, header_write_data);
+  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEHEADER, (void *)&header);
+
+#ifdef MSG_LAF_VERBOSE
+  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_VERBOSE, 1);
 #endif
 
@@ -227,22 +236,22 @@
   switch(dwFlags)
     {
-    case INTERNET_FLAG_NO_CACHE_WRITE:    
-      hInternet.hasCacheFile=-1;
-      curl_easy_setopt(hInternet.ihandle, CURLOPT_WRITEFUNCTION, write_data_into);
-      curl_easy_setopt(hInternet.ihandle, CURLOPT_WRITEDATA, &hInternet);
+    case INTERNET_FLAG_NO_CACHE_WRITE:
+      hInternet->ihandle[hInternet->nb].hasCacheFile=-1;
+      curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEFUNCTION, write_data_into);
+      curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEDATA, (void*)&hInternet->ihandle[hInternet->nb]);
       break;
     default:
-      sprintf(filename,"/tmp/ZOO_Cache%d",(int)time(NULL));
-      filename[24]=0;
-#ifdef MSG_LAF_VERBOSE
-      fprintf(stderr,"file=%s",filename);
-#endif
-      hInternet.filename=filename;
-      hInternet.file=fopen(hInternet.filename,"w+");
+      sprintf(hInternet->ihandle[hInternet->nb].filename,"/tmp/ZOO_Cache%d",(int)time(NULL));
+      hInternet->ihandle[hInternet->nb].filename[24]=0;
+#ifdef MSG_LAF_VERBOSE
+      fprintf(stderr,"file=%s",hInternet->ihandle[hInternet->nb].filename);
+#endif
+      hInternet->ihandle[hInternet->nb].filename=filename;
+      hInternet->ihandle[hInternet->nb].file=fopen(hInternet->ihandle[hInternet->nb].filename,"w+");
     
-      hInternet.hasCacheFile=1;
-      curl_easy_setopt(hInternet.ihandle, CURLOPT_WRITEFUNCTION, NULL);
-      curl_easy_setopt(hInternet.ihandle, CURLOPT_WRITEDATA, hInternet.file);
-      hInternet.nDataLen=0;
+      hInternet->ihandle[hInternet->nb].hasCacheFile=1;
+      curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEFUNCTION, NULL);
+      curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEDATA, hInternet->ihandle[hInternet->nb].file);
+      hInternet->ihandle[hInternet->nb].nDataLen=0;
       break;
     }
@@ -255,38 +264,21 @@
     fprintf(stderr,"HEADER : %s\n",lpszHeaders);
 #endif
-    //curl_easy_setopt(hInternet.handle,CURLOPT_COOKIE,lpszHeaders);
-    curl_easy_setopt(hInternet.ihandle,CURLOPT_POST,1);
+    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POST,1);
 #ifdef ULINET_DEBUG
     fprintf(stderr,"** (%s) %d **\n",lpszHeaders,dwHeadersLength);
-    curl_easy_setopt(hInternet.ihandle,CURLOPT_VERBOSE,1);
-#endif
-    curl_easy_setopt(hInternet.ihandle,CURLOPT_POSTFIELDS,lpszHeaders);
-    //curl_easy_setopt(hInternet.handle,CURLOPT_POSTFIELDSIZE,dwHeadersLength+1);
-    if(hInternet.header!=NULL)
-      curl_easy_setopt(hInternet.ihandle,CURLOPT_HTTPHEADER,hInternet.header);
-  }
-
-  curl_easy_setopt(hInternet.ihandle,CURLOPT_URL,lpszUrl);
-
-  curl_multi_add_handle(hInternet.handle,hInternet.ihandle);
-  
-  int still_running=0;
-  int msgs_left=0;
-  do{
-    curl_multi_perform(hInternet.handle, &still_running);
-  }while(still_running);
-
-  CURLMsg *msg=NULL;
-  while ((msg = curl_multi_info_read(hInternet.handle, &msgs_left))) {
-    if (msg->msg == CURLMSG_DONE) {
-      CURL *eh=NULL;
-      eh = msg->easy_handle;
-      curl_easy_getinfo(eh,CURLINFO_CONTENT_TYPE,&hInternet.mimeType);
-    }
-    else {
-      fprintf(stderr, "error: after curl_multi_info_read(), CURLMsg=%d\n", msg->msg);
-    }
-  }
-  curl_multi_remove_handle(hInternet.handle, hInternet.ihandle);
+    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_VERBOSE,1);
+#endif
+    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POSTFIELDS,lpszHeaders);
+    //curl_easy_setopt(hInternet->handle,CURLOPT_POSTFIELDSIZE,dwHeadersLength+1);
+    if(hInternet->ihandle[hInternet->nb].header!=NULL)
+      curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_HTTPHEADER,hInternet->ihandle[hInternet->nb].header);
+  }
+
+  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_URL,lpszUrl);
+
+  curl_multi_add_handle(hInternet->handle,hInternet->ihandle[hInternet->nb].handle);
+  
+  ++hInternet->nb;
+  hInternet->ihandle[hInternet->nb].header=NULL;
 
 #ifdef ULINET_DEBUG
@@ -294,16 +286,30 @@
   fflush(stderr);
 #endif
-  return hInternet;
+  return *hInternet;
 };
 
+int processDownloads(HINTERNET* hInternet){
+  int still_running=0;
+  int msgs_left=0;
+  int i=0;
+  do{
+    curl_multi_perform(hInternet->handle, &still_running);
+  }while(still_running);  
+  for(i=0;i<hInternet->nb;i++){
+    curl_easy_getinfo(hInternet->ihandle[i].handle,CURLINFO_CONTENT_TYPE,&hInternet->ihandle[i].mimeType);
+    curl_multi_remove_handle(hInternet->handle, hInternet->ihandle[i].handle);
+    curl_easy_cleanup(hInternet->ihandle[i].handle);
+  }
+}
+
 int freeCookieList(HINTERNET hInternet){
-  memset(&CCookie[0],0,1024);
+  memset(&CCookie[hInternet.nb][0],0,1024);
 #ifndef TIGER
-  curl_easy_setopt(hInternet.ihandle, CURLOPT_COOKIELIST, "ALL");
+  curl_easy_setopt(hInternet.ihandle[hInternet.nb].handle, CURLOPT_COOKIELIST, "ALL");
 #endif
   return 1;
 }
 
-int InternetReadFile(HINTERNET hInternet,LPVOID lpBuffer,int dwNumberOfBytesToRead, size_t *lpdwNumberOfBytesRead){
+int InternetReadFile(_HINTERNET hInternet,LPVOID lpBuffer,int dwNumberOfBytesToRead, size_t *lpdwNumberOfBytesRead){
   int dwDataSize;
 
@@ -338,5 +344,5 @@
   }
 
-  CCookie[0]=0;
+  CCookie[hInternet.id][0]=0;
 
   if( *lpdwNumberOfBytesRead < dwDataSize )
@@ -346,52 +352,2 @@
 }
 
-bool InternetGetCookie(LPCTSTR lpszUrl,LPCTSTR lpszCookieName,LPTSTR lpszCookieData,LPDWORD lpdwSize){
-
-  bool ret=1;  
-  int count=0;
-  int hasCookie=-1;
-  char TMP[1024];
-  int j;
-  int tmpC=0;
-  lpszUrl=NULL;
-
-  for(j=0;j<strlen(CCookie);j++){
-    if(lpszCookieName[count]==CCookie[j]){
-      hasCookie=1;
-      count++;
-      if(count==strlen(lpszCookieName))
-	break;
-      continue;
-    }
-  }
-
-  if(hasCookie>0){
-    if(CCookie[count]=='='){
-      int i=0;
-      count++;
-      for(i=count;i<strlen(CCookie);i++){
-	if(CCookie[i]!=';'){
-	  TMP[tmpC]=CCookie[i];
-	  tmpC++;
-	}
-	else{
-	  break;
-	}
-      }
-    }
-  }
-  else
-    return -1;
-
-  TMP[tmpC]=0;
-  strncpy(lpszCookieData,TMP,strlen(TMP)+1);
-  lpdwSize=(size_t*) strlen(lpszCookieData);
-
-#ifdef MSG_LAF_VERBOSE
-  printf("Cookie returned : (%s)",(char*)lpszCookieData);
-#endif
-
-  return ret;
-
-}
-
Index: trunk/zoo-project/zoo-kernel/ulinet.h
===================================================================
--- trunk/zoo-project/zoo-kernel/ulinet.h	(revision 490)
+++ trunk/zoo-project/zoo-kernel/ulinet.h	(revision 492)
@@ -27,4 +27,5 @@
 
 #include "fcgi_stdio.h"
+#include "service.h"
 #include <stdlib.h>
 #include <fcntl.h>
@@ -44,10 +45,11 @@
 #endif
 
+#define MAX_REQ 100
 
 #ifdef _ULINET
-static char CCookie[1024];
+static char CCookie[MAX_REQ][1024];
 #else
-extern char HEADER[3072];
-extern char CCookie[1024];
+extern char HEADER[MAX_REQ][3072];
+extern char CCookie[MAX_REQ][1024];
 #endif
 
@@ -58,4 +60,6 @@
   //static pthread_mutex_t hMutexConnect = PTHREAD_MUTEX_INITIALIZER;
 
+static char* waitingRequests[MAX_REQ];
+
 struct MemoryStruct {
   char *memory;
@@ -64,16 +68,23 @@
 
 typedef struct {
-  CURLM *handle;
-  CURL *ihandle;
+  CURL *handle;
   struct curl_slist *header;
   char* filename;
-  char *agent;
   FILE* file;
   size_t size;
+  unsigned char *pabyData;
+  unsigned char *mimeType;
   int hasCacheFile;
   int nDataLen;
   int nDataAlloc;
-  unsigned char *pabyData;
-  unsigned char *mimeType;
+  int id;
+} _HINTERNET;
+
+typedef struct {
+  CURLM *handle;
+  _HINTERNET ihandle[MAX_REQ];
+  char *waitingRequests[MAX_REQ];
+  char *agent;
+  int nb;
 } HINTERNET;
 
@@ -112,5 +123,5 @@
 HINTERNET InternetOpen(char* lpszAgent,int dwAccessType,char* lpszProxyName,char* lpszProxyBypass,int dwFlags);
 
-void InternetCloseHandle(HINTERNET handle);
+void InternetCloseHandle(HINTERNET* handle);
 
 #define INTERNET_FLAG_EXISTING_CONNECT         0
@@ -137,11 +148,11 @@
 #  define CHECK_INET_HANDLE(h) (h.handle != 0)
 
-HINTERNET InternetOpenUrl(HINTERNET hInternet,LPCTSTR lpszUrl,LPCTSTR lpszHeaders,size_t dwHeadersLength,size_t dwFlags,size_t dwContext);
+HINTERNET InternetOpenUrl(HINTERNET* hInternet,LPCTSTR lpszUrl,LPCTSTR lpszHeaders,size_t dwHeadersLength,size_t dwFlags,size_t dwContext);
+
+int processDownloads(HINTERNET* hInternet);
 
 int freeCookieList(HINTERNET hInternet);
 
-int InternetReadFile(HINTERNET hInternet,LPVOID lpBuffer,int dwNumberOfBytesToRead,size_t *lpdwNumberOfBytesRead);
-
-bool InternetGetCookie(LPCTSTR lpszUrl,LPCTSTR lpszCookieName,LPTSTR lpszCookieData,LPDWORD lpdwSize);
+int InternetReadFile(_HINTERNET hInternet,LPVOID lpBuffer,int dwNumberOfBytesToRead,size_t *lpdwNumberOfBytesRead);
 
 #ifdef __cplusplus
Index: trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 490)
+++ trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 492)
@@ -257,4 +257,5 @@
 #endif
 	t=readServiceFile(m,tmps1,&s1,dp->d_name);
+
 	if(t<0){
 	  dumpMaps(m);
@@ -961,4 +962,5 @@
 	char buff1[1024];
 	while(tmps!=NULL){
+	  int hasVal=-1;
 	  char *corig=strdup(tmps);
 	  if(strstr(corig,".")!=NULL){
@@ -966,4 +968,5 @@
 	    s1=(service*)malloc(SERVICE_SIZE);
 	    t=readServiceFile(m,buff1,&s1,corig);
+
 	    if(t<0){
 	      map* tmp00=getMapFromMaps(m,"lenv","message");
@@ -977,4 +980,5 @@
 	      freeMaps(&m);
 	      free(m);
+	      free(REQUEST);
 	      return 1;
 	    }
@@ -989,15 +993,14 @@
 	    setMapInMaps(m,"lenv","level","0");
 	  }
-	  free(corig);
 	  
 	  memset(buff,0,256);
-	  snprintf(buff,256,"%s.zcfg",tmps);
+	  snprintf(buff,256,"%s.zcfg",corig);
+	  free(corig);
 	  memset(buff1,0,1024);
 #ifdef DEBUG
 	  printf("\n#######%s\n########\n",buff);
 #endif
-	  while ((dp = readdir(dirp)) != NULL)
-	    if( (strcasecmp("all.zcfg",buff)==0 && strstr(dp->d_name,".zcfg")>0)
-		|| strcasecmp(dp->d_name,buff)==0 ){
+	  while ((dp = readdir(dirp)) != NULL){
+	    if( strcasecmp(dp->d_name,buff)==0 ){
 	      memset(buff1,0,1024);
 	      snprintf(buff1,1024,"%s/%s",conf_dir,dp->d_name);
@@ -1025,4 +1028,8 @@
 		freeMaps(&m);
 		free(m);
+		free(orig);
+		free(REQUEST);
+		closedir(dirp);
+		xmlFreeDoc(doc);
 		return 1;
 	      }
@@ -1035,5 +1042,24 @@
 	      s1=NULL;
 	      scount++;
+	      hasVal=1;
 	    }
+	  }
+	  if(hasVal<0){
+	    map* tmp00=getMapFromMaps(m,"lenv","message");
+	    char tmp01[1024];
+	    if(tmp00!=NULL)
+	      sprintf(tmp01,_("Unable to parse the ZCFG file: %s (%s)"),buff,tmp00->value);
+	    else
+	      sprintf(tmp01,_("Unable to parse the ZCFG file: %s."),buff);
+	    dup2(saved_stdout,fileno(stdout));
+	    errorException(m, tmp01,"InvalidParameterValue","Identifier");
+	    freeMaps(&m);
+	    free(m);
+	    free(orig);
+	    free(REQUEST);
+	    closedir(dirp);
+	    xmlFreeDoc(doc);
+	    return 1;
+	  }
 	  rewinddir(dirp);
 	  tmps=strtok_r(NULL,",",&saveptr);
@@ -1271,5 +1297,5 @@
       free(REQUEST);
       free(SERVICE_URL);
-      InternetCloseHandle(hInternet);
+      InternetCloseHandle(&hInternet);
       freeService(&s1);
       free(s1);
@@ -1399,5 +1425,5 @@
 		free(REQUEST);
 		free(SERVICE_URL);
-		InternetCloseHandle(hInternet);
+		InternetCloseHandle(&hInternet);
 		freeService(&s1);
 		free(s1);
@@ -1407,16 +1433,15 @@
 	      fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1);
 #endif
-	      addToMap(tmpmaps->content,tmpn1,tmpx2);
-	      
+	      addToMap(tmpmaps->content,tmpn1,tmpx2);	      
 #ifndef WIN32
 	      if(CHECK_INET_HANDLE(hInternet))
 #endif
 		{
-		  if(loadRemoteFile(&m,&tmpmaps->content,hInternet,tmpx2)<0){
+		  if(loadRemoteFile(&m,&tmpmaps->content,&hInternet,tmpx2)<0){
 		    freeMaps(&m);
 		    free(m);
 		    free(REQUEST);
 		    free(SERVICE_URL);
-		    InternetCloseHandle(hInternet);
+		    InternetCloseHandle(&hInternet);
 		    freeService(&s1);
 		    free(s1);
@@ -1445,5 +1470,5 @@
 		free(REQUEST);
 		free(SERVICE_URL);
-		InternetCloseHandle(hInternet);
+		InternetCloseHandle(&hInternet);
 		freeService(&s1);
 		free(s1);
@@ -1575,10 +1600,10 @@
 		  if(!(ltmp!=NULL && strncmp(ltmp->value,"POST",4)==0)
 		     && CHECK_INET_HANDLE(hInternet)){
-		    if(loadRemoteFile(&m,&tmpmaps->content,hInternet,(char*)val)!=0){
+		    if(loadRemoteFile(&m,&tmpmaps->content,&hInternet,(char*)val)!=0){
 		      freeMaps(&m);
 		      free(m);
 		      free(REQUEST);
 		      free(SERVICE_URL);
-		      InternetCloseHandle(hInternet);
+		      InternetCloseHandle(&hInternet);
 		      freeService(&s1);
 		      free(s1);
@@ -1597,5 +1622,5 @@
 #endif
 	    xmlNodePtr cur3=cur2->children;
-	    HINTERNET hInternetP;
+	    /*	    HINTERNET hInternetP;
 	    hInternetP=InternetOpen(
 #ifndef WIN32
@@ -1604,6 +1629,6 @@
 				   "ZooWPSClient\0",
 				   INTERNET_OPEN_TYPE_PRECONFIG,
-				   NULL,NULL, 0);
-	    hInternetP.header=NULL;
+				   NULL,NULL, 0);*/
+	    //hInternet.ihandle[hInternet.nb].header=NULL;
 	    while(cur3!=NULL){
 	      while(cur3!=NULL && cur3->type!=XML_ELEMENT_NODE)
@@ -1638,5 +1663,5 @@
 		  xmlFree(val);
 		}
-		hInternetP.header=curl_slist_append(hInternetP.header, has);
+		hInternet.ihandle[hInternet.nb].header=curl_slist_append(hInternet.ihandle[hInternet.nb].header, has);
 		if(has!=NULL)
 		  free(has);
@@ -1675,23 +1700,9 @@
 #ifdef POST_DEBUG
 		    fprintf(stderr,"%s %s\n",btmp->value,tmp);
-		    curl_easy_setopt(hInternetP.handle, CURLOPT_VERBOSE, 1);
-#endif
-		    res=InternetOpenUrl(hInternetP,btmp->value,tmp,strlen(tmp),
+		    curl_easy_setopt(hInternet.handle, CURLOPT_VERBOSE, 1);
+#endif
+		    hInternet.waitingRequests[hInternet.nb]=strdup(tmp);
+		    InternetOpenUrl(&hInternet,btmp->value,hInternet.waitingRequests[hInternet.nb],strlen(hInternet.waitingRequests[hInternet.nb]),
 					INTERNET_FLAG_NO_CACHE_WRITE,0);
-		    char* tmpContent = (char*)malloc((res.nDataLen+1)*sizeof(char));
-		    if(tmpContent == NULL){
-		      return errorException(m, _("Unable to allocate memory."), "InternalError",NULL);
-		    }
-		    size_t dwRead;
-		    InternetReadFile(res, (LPVOID)tmpContent,
-				     res.nDataLen, &dwRead);
-		    tmpContent[res.nDataLen]=0;
-		    if(hInternetP.header!=NULL)
-		      curl_slist_free_all(hInternetP.header);
-		    addToMap(tmpmaps->content,"value",tmpContent);
-		    free(tmpContent);
-#ifdef POST_DEBUG
-		    fprintf(stderr,"DL CONTENT : (%s)\n",tmpContent);
-#endif		    
 		  }
 		  free(tmp);
@@ -1708,50 +1719,38 @@
 					   INTERNET_OPEN_TYPE_PRECONFIG,
 					   NULL,NULL, 0);
-		    if(!CHECK_INET_HANDLE(bInternet))
+		    if(!CHECK_INET_HANDLE(hInternet))
 		      fprintf(stderr,"WARNING : hInternet handle failed to initialize");
 #ifdef POST_DEBUG
 		    curl_easy_setopt(bInternet.handle, CURLOPT_VERBOSE, 1);
 #endif
-		    res1=InternetOpenUrl(bInternet,(char*)val,NULL,0,
+		    bInternet.waitingRequests[0]=strdup((char*)val);
+		    res1=InternetOpenUrl(&bInternet,bInternet.waitingRequests[0],NULL,0,
 					 INTERNET_FLAG_NO_CACHE_WRITE,0);
+		    processDownloads(&bInternet);
 		    char* tmp=
-		      (char*)malloc((res1.nDataLen+1)*sizeof(char));
+		      (char*)malloc((bInternet.ihandle[0].nDataLen+1)*sizeof(char));
 		    if(tmp == NULL){
 		      return errorException(m, _("Unable to allocate memory."), "InternalError",NULL);
 		    }
 		    size_t bRead;
-		    InternetReadFile(res1, (LPVOID)tmp,
-				     res1.nDataLen, &bRead);
-		    tmp[res1.nDataLen]=0;
-		    InternetCloseHandle(bInternet);
+		    InternetReadFile(bInternet.ihandle[0], (LPVOID)tmp,
+				     bInternet.ihandle[0].nDataLen, &bRead);
+		    tmp[bInternet.ihandle[0].nDataLen]=0;
+		    InternetCloseHandle(&bInternet);
 		    map *btmp=getMap(tmpmaps->content,"href");
 		    if(btmp!=NULL){
 #ifdef POST_DEBUG
 		      fprintf(stderr,"%s %s\n",btmp->value,tmp);
-		      curl_easy_setopt(hInternetP.handle, CURLOPT_VERBOSE, 1);
-#endif
-		      res=InternetOpenUrl(hInternetP,btmp->value,tmp,
-					  strlen(tmp),
+#endif
+		      hInternet.waitingRequests[hInternet.nb]=strdup(tmp);
+		      res=InternetOpenUrl(&hInternet,btmp->value,hInternet.waitingRequests[hInternet.nb],
+					  strlen(hInternet.waitingRequests[hInternet.nb]),
 					  INTERNET_FLAG_NO_CACHE_WRITE,0);
-		      char* tmpContent = (char*)malloc((res.nDataLen+1)*sizeof(char));
-		      if(tmpContent == NULL){
-			return errorException(m, _("Unable to allocate memory."), "InternalError",NULL);
-		      }
-		      size_t dwRead;
-		      InternetReadFile(res, (LPVOID)tmpContent,
-				       res.nDataLen, &dwRead);
-		      tmpContent[res.nDataLen]=0;
-		      if(hInternetP.header!=NULL)
-			curl_slist_free_all(hInternetP.header);
-		      addToMap(tmpmaps->content,"value",tmpContent);
-#ifdef POST_DEBUG
-		      fprintf(stderr,"DL CONTENT : (%s)\n",tmpContent);
-#endif
 		    }
+		    free(tmp);
 		  }
 	      }
 	      cur3=cur3->next;
 	    }
-	    InternetCloseHandle(hInternetP);
 #ifdef POST_DEBUG
 	    fprintf(stderr,"Header and Body was parsed from Reference \n");
@@ -1901,5 +1900,5 @@
 		free(REQUEST);
 		free(SERVICE_URL);
-		InternetCloseHandle(hInternet);
+		InternetCloseHandle(&hInternet);
 		freeService(&s1);
 		free(s1);
@@ -2148,7 +2147,8 @@
   }
   
+  runHttpRequests(&m,&request_input_real_format,&hInternet);
 
   //  if(CHECK_INET_HANDLE(hInternet))
-  InternetCloseHandle(hInternet);
+  InternetCloseHandle(&hInternet);
 
 #ifdef DEBUG
