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);
