Index: trunk/zoo-project/zoo-kernel/caching.c
===================================================================
--- trunk/zoo-project/zoo-kernel/caching.c	(revision 815)
+++ trunk/zoo-project/zoo-kernel/caching.c	(revision 817)
@@ -292,4 +292,5 @@
   int hasAFailure=0;
   if(hInternet!=NULL && hInternet->nb>0){
+    AddHeaderEntries(hInternet,*m);
     processDownloads(hInternet);
     maps* content=*inputs;
Index: trunk/zoo-project/zoo-kernel/configure.ac
===================================================================
--- trunk/zoo-project/zoo-kernel/configure.ac	(revision 815)
+++ trunk/zoo-project/zoo-kernel/configure.ac	(revision 817)
@@ -1,3 +1,3 @@
-AC_INIT([ZOO Kernel], [1.6.0], [bugs@zoo-project.org])
+AC_INIT([ZOO Kernel], [1.7.0], [bugs@zoo-project.org])
 
 # Checks for programs.
Index: trunk/zoo-project/zoo-kernel/ulinet.c
===================================================================
--- trunk/zoo-project/zoo-kernel/ulinet.c	(revision 815)
+++ trunk/zoo-project/zoo-kernel/ulinet.c	(revision 817)
@@ -30,4 +30,5 @@
 #include "ulinet.h"
 #include <assert.h>
+#include <ctype.h>
 
 /**
@@ -219,4 +220,98 @@
 
 /**
+ * Add missing headers to an existing _HINTERNET
+ * 
+ * 
+ * @param handle the _HINTERNET pointer
+ * @param key the header parameter name
+ * @param value the header parameter value
+ * @return 0 if the operation succeeded, -1 in other case.
+ */
+int AddMissingHeaderEntry(_HINTERNET* handle,const char* key,const char* value){
+  int length=strlen(key)+strlen(value)+3;
+  char *entry=(char*)malloc((length)*sizeof(char));
+  if(entry==NULL)
+    return -1;
+  snprintf (entry, length, "%s: %s", key, value);
+  handle->header = curl_slist_append (handle->header, entry);
+  free(entry);
+  return 0;
+}
+
+/**
+ * Verify if a host is protected (appear in [security] > hosts)
+ *
+ * @param protectedHosts string containing all the protected hosts (coma separated)
+ * @param url string used to extract the host from
+ * @return 1 if the host is listed as protected, 0 in other case
+ */
+int isProtectedHost(const char* protectedHosts,const char* url){
+  char *token, *saveptr;
+  token = strtok_r (url, "//", &saveptr);
+  int cnt=0;
+  char* host;
+  while(token!=NULL && cnt<=1){
+    fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,token);
+    if(cnt==1)
+      fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,strstr(protectedHosts,token));
+    fflush(stderr);
+    if(cnt==1 && strstr(protectedHosts,token)!=NULL){
+      fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,strstr(protectedHosts,token));
+      return 1;
+    }
+    token = strtok_r (NULL, "/", &saveptr);
+    cnt+=1;
+  }
+  return 0;
+}
+
+/**
+ * Add headers defined in [security] > attributes to an existing HINTERNET
+ * @see isProtectedHost, AddMissingHeaderEntry
+ * 
+ * @param handle the _HINTERNET pointer
+ * @param conf the header parameter name
+ * @param value the header parameter value
+ * @return 0 if the operation succeeded, -1 in other case.
+ */
+void AddHeaderEntries(HINTERNET* handle,maps* conf){
+  map* passThrough=getMapFromMaps(conf,"security","attributes");
+  map* targetHosts=getMapFromMaps(conf,"security","hosts");
+  char* passedHeader[10];
+  int cnt=0;
+  if(passThrough!=NULL && targetHosts!=NULL){
+    char *tmp=zStrdup(passThrough->value);
+    char *token, *saveptr;
+    token = strtok_r (tmp, ",", &saveptr);
+    for(int i=0;i<handle->nb;i++){
+      if(targetHosts->value[0]=='*' || isProtectedHost(targetHosts->value,handle->ihandle[i].url)==1){
+	while (token != NULL){
+	  int length=strlen(token)+6;
+	  char* tmp1=(char*)malloc(length*sizeof(char));
+	  snprintf(tmp1,6,"HTTP_");
+	  for(int i=0;token[i]!='\0';i++){
+	    if(token[i]!='-')
+	      tmp1[5+i]=toupper(token[i]);
+	    else
+	      tmp1[5+i]='_';
+	    tmp1[5+i+1]='\0';
+	  }
+	  fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,tmp1);
+	  map* tmpMap = getMapFromMaps(conf,"renv",tmp1);
+	  if(tmpMap!=NULL)	    
+	    AddMissingHeaderEntry(&handle->ihandle[i],token,tmpMap->value);
+	  free(tmp1);
+	  if(handle->ihandle[i].header!=NULL)
+	    curl_easy_setopt(handle->ihandle[i].handle,CURLOPT_HTTPHEADER,handle->ihandle[i].header);
+	  cnt+=1;
+	  token = strtok_r (NULL, ",", &saveptr);
+	}
+      }
+    }
+    free(tmp);
+  }
+}
+
+/**
  * Close a HINTERNET connection and free allocated resources
  *
@@ -241,4 +336,6 @@
     if(handle.post!=NULL)
       free(handle.post);
+    if(handle.url!=NULL)
+      free(handle.url);
     free(handle.mimeType);
     handle.mimeType = NULL;
@@ -270,4 +367,5 @@
   hInternet->ihandle[hInternet->nb].hasCacheFile=0;
   hInternet->ihandle[hInternet->nb].nDataAlloc = 0;
+  hInternet->ihandle[hInternet->nb].url = NULL;
   hInternet->ihandle[hInternet->nb].mimeType = NULL;
   hInternet->ihandle[hInternet->nb].nDataLen = 0;
@@ -340,4 +438,5 @@
 
   curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_URL,lpszUrl);
+  hInternet->ihandle[hInternet->nb].url = zStrdup(lpszUrl);
 
   curl_multi_add_handle(hInternet->handle,hInternet->ihandle[hInternet->nb].handle);
Index: trunk/zoo-project/zoo-kernel/ulinet.h
===================================================================
--- trunk/zoo-project/zoo-kernel/ulinet.h	(revision 815)
+++ trunk/zoo-project/zoo-kernel/ulinet.h	(revision 817)
@@ -30,4 +30,5 @@
 #include <fcntl.h>
 #include <curl/curl.h>
+#include "service.h"
 #ifndef WIN32
 #include <unistd.h>
@@ -84,4 +85,5 @@
     FILE* file; //!< the file pointer
     unsigned char *pabyData; //!< the downloaded content
+    char *url; //!< the url used to access the server
     char *mimeType; //!< the mimeType returned by the server
     char *post; //!< the potential POST XML content
@@ -134,4 +136,8 @@
   HINTERNET InternetOpen(char*,int,char*,char*,int);
 
+  int isProtectedHost(const char*,const char*);
+  int AddMissingHeaderEntry(_HINTERNET*,const char*,const char*);
+  void AddHeaderEntries(HINTERNET*,maps*);
+
   void InternetCloseHandle(HINTERNET*);
 
Index: trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 815)
+++ trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 817)
@@ -2100,6 +2100,6 @@
               addMapsToMaps (&m, tmpSess);
               freeMaps (&tmpSess);
-              free (tmpSess);
             }
+	  free (tmpSess);
         }
     }
