Ignore:
Timestamp:
Jul 11, 2014, 10:14:03 PM (10 years ago)
Author:
djay
Message:

Inputs passed by reference downloaded in parallel. Conform behavior for DescribeProcess? when the Identifier was not found.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/service_internal.c

    r490 r492  
    18711871      if(testMap!=NULL){
    18721872        HINTERNET hInternet;
     1873        char* tmpValue;
     1874        size_t dwRead;
    18731875        hInternet=InternetOpen(
    18741876#ifndef WIN32
     
    18791881                               NULL,NULL, 0);
    18801882        testMap=getMap(m->content,"Reference");
    1881         loadRemoteFile(&m,&m->content,hInternet,testMap->value);
    1882         InternetCloseHandle(hInternet);
     1883        loadRemoteFile(&m,&m->content,&hInternet,testMap->value);
     1884        processDownloads(&hInternet);
     1885        tmpValue=(char*)malloc((hInternet.ihandle[0].nDataLen+1)*sizeof(char));
     1886        InternetReadFile(hInternet.ihandle[0],(LPVOID)tmpValue,hInternet.ihandle[0].nDataLen,&dwRead);
     1887        InternetCloseHandle(&hInternet);
    18831888      }
    18841889#endif
     
    19631968        else
    19641969#endif
    1965           xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
     1970          if(strcasecmp(tmp->name,"datatype")==0)
     1971            xmlNewProp(nc3,BAD_CAST "mimeType",BAD_CAST "text/plain");
     1972          else
     1973            xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
    19661974      }
    19671975      tmp=tmp->next;
     
    28722880    fprintf(stderr,"MIMETYPE: %s\n",mimeType);
    28732881#endif
    2874     fwrite(mimeType,1,strlen(mimeType),fo);
     2882    fwrite(mimeType,sizeof(char),strlen(mimeType),fo);
    28752883    fclose(fo);
    28762884
     
    29012909}
    29022910
     2911int runHttpRequests(maps** m,maps** inputs,HINTERNET* hInternet){
     2912  if(hInternet->nb>0){
     2913    processDownloads(hInternet);
     2914    maps* content=*inputs;
     2915    map* tmp1;
     2916    int index=0;
     2917    while(content!=NULL){
     2918      if((tmp1=getMap(content->content,"href")) ||
     2919         (tmp1=getMap(content->content,"xlink:href"))){
     2920        if(getMap(content->content,"isCached")==NULL){
     2921          char* fcontent;
     2922          char *mimeType=NULL;
     2923          int fsize=0;
     2924
     2925          fcontent=(char*)malloc((hInternet->ihandle[index].nDataLen+1)*sizeof(char));
     2926          if(fcontent == NULL){
     2927            return errorException(*m, _("Unable to allocate memory."), "InternalError",NULL);
     2928          }
     2929          size_t dwRead;
     2930          InternetReadFile(hInternet->ihandle[index],
     2931                           (LPVOID)fcontent,
     2932                           hInternet->ihandle[index].nDataLen,
     2933                           &dwRead);
     2934          fcontent[hInternet->ihandle[index].nDataLen]=0;
     2935          fsize=hInternet->ihandle[index].nDataLen;
     2936          mimeType=strdup((char*)hInternet->ihandle[index].mimeType);
     2937         
     2938          map* tmpMap=getMapOrFill(&content->content,"value","");
     2939          free(tmpMap->value);
     2940          tmpMap->value=(char*)malloc((fsize+1)*sizeof(char));
     2941          if(tmpMap->value==NULL){
     2942            return errorException(*m, _("Unable to allocate memory."), "InternalError",NULL);
     2943          }
     2944          memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char));
     2945         
     2946          char ltmp1[256];
     2947          sprintf(ltmp1,"%d",fsize);
     2948          addToMap(content->content,"size",ltmp1);
     2949          addToCache(*m,tmp1->value,fcontent,mimeType,fsize);
     2950          free(fcontent);
     2951          free(mimeType);
     2952        }
     2953        index++;
     2954      }
     2955      content=content->next;
     2956    }
     2957  }
     2958}
     2959
    29032960/**
    29042961 * loadRemoteFile:
    29052962 * Try to load file from cache or download a remote file if not in cache
    29062963 */
    2907 int loadRemoteFile(maps** m,map** content,HINTERNET hInternet,char *url){
    2908   HINTERNET res;
     2964int loadRemoteFile(maps** m,map** content,HINTERNET* hInternet,char *url){
    29092965  char* fcontent;
    29102966  char* cached=isInCache(*m,url);
     
    29322988    }
    29332989  }else{
    2934     res=InternetOpenUrl(hInternet,url,NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0);
    2935     fcontent=(char*)malloc((res.nDataLen+1)*sizeof(char));
    2936     if(fcontent == NULL){
    2937       return errorException(*m, _("Unable to allocate memory."), "InternalError",NULL);
    2938     }
    2939     size_t dwRead;
    2940     InternetReadFile(res, (LPVOID)fcontent, res.nDataLen, &dwRead);
    2941     fcontent[res.nDataLen]=0;
    2942     fsize=res.nDataLen;
    2943     mimeType=(char*)res.mimeType;
     2990    hInternet->waitingRequests[hInternet->nb]=strdup(url);
     2991    InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0);
     2992    return 0;
    29442993  }
    29452994  if(fsize==0){
    29462995    return errorException(*m, _("Unable to download the file."), "InternalError",NULL);
    29472996  }
    2948 
    29492997  if(mimeType!=NULL){
    29502998    addToMap(*content,"fmimeType",mimeType);
     
    29573005  if(tmpMap->value==NULL)
    29583006    return errorException(*m, _("Unable to allocate memory."), "InternalError",NULL);
    2959   //snprintf(tmpMap->value,(fsize+1)*sizeof(char),fcontent);
    29603007  memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char));
    29613008 
     
    29653012  if(cached==NULL)
    29663013    addToCache(*m,url,fcontent,mimeType,fsize);
     3014  else
     3015    addToMap(*content,"isCached","true");
    29673016  free(fcontent);
    29683017  free(mimeType);
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png