Ignore:
Timestamp:
Jul 10, 2019, 2:38:34 PM (5 years ago)
Author:
djay
Message:

Fix #172 and add the documentation on how to use the curl section to define cainfo.

Location:
trunk/zoo-project/zoo-kernel
Files:
2 edited

Legend:

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

    r917 r944  
    8282{
    8383   size_t realsize = size * nmemb;
    84    int writen=0;
     84   size_t writen=0;
    8585   _HINTERNET *psInternet;
    8686   if(buffer==NULL){
     
    306306 */
    307307int AddMissingHeaderEntry(_HINTERNET* handle,const char* key,const char* value){
    308   int length=strlen(key)+strlen(value)+3;
     308  size_t length=strlen(key)+strlen(value)+3;
    309309  char *entry=(char*)malloc((length)*sizeof(char));
    310310  if(entry==NULL)
     
    326326        char *token, *saveptr;
    327327        int cnt;
    328         char* host;
    329328
    330329        // knut: make a copy of url since strtok family modifies first argument and cannot be used on constant strings 
     
    374373        token = strtok_r (tmp, ",", &saveptr);
    375374        while (token != NULL){
    376           int length=strlen(token)+6;
     375          size_t length=strlen(token)+6;
    377376          char* tmp1=(char*)malloc(length*sizeof(char));
    378377          map* tmpMap;
     
    414413      if(handle.hasCacheFile>0){
    415414        fclose(handle.file);
    416         unlink(handle.filename);
     415        zUnlink(handle.filename);
    417416        free(handle.filename);
    418417      }
     
    483482  hInternet->ihandle[hInternet->nb].id = hInternet->nb;
    484483  hInternet->ihandle[hInternet->nb].nDataAlloc = 0;
     484  hInternet->ihandle[hInternet->nb].code = -1;
    485485  hInternet->ihandle[hInternet->nb].pabyData = NULL;
    486486  hInternet->ihandle[hInternet->nb].post = NULL;
    487  
     487
     488  map* caBundle=getMapFromMaps((maps*) conf,"curl","cainfo");
     489  if(caBundle!=NULL)
     490    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_CAINFO,caBundle->value);
    488491  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_COOKIEFILE, "ALL");
    489492#ifndef TIGER
     
    626629    if(tmp!=NULL)
    627630      hInternet->ihandle[i].mimeType=zStrdup(tmp);
    628     curl_easy_getinfo(hInternet->ihandle[i].handle,CURLINFO_RESPONSE_CODE,&hInternet->ihandle[i].code);
     631    curl_easy_getinfo(hInternet->ihandle[i].handle,CURLINFO_RESPONSE_CODE,&(hInternet->ihandle[i].code));
    629632    curl_multi_remove_handle(hInternet->handle, hInternet->ihandle[i].handle);
    630633    curl_easy_cleanup(hInternet->ihandle[i].handle);
     
    658661 */
    659662int InternetReadFile(_HINTERNET hInternet,LPVOID lpBuffer,int dwNumberOfBytesToRead, size_t *lpdwNumberOfBytesRead){
    660   int dwDataSize;
     663  size_t dwDataSize;
    661664
    662665  if(hInternet.hasCacheFile>0){
     
    684687
    685688  if(hInternet.hasCacheFile>0){
    686     int freadRes = fread(lpBuffer,dwDataSize+1,1,hInternet.file);
     689    size_t freadRes = fread(lpBuffer,dwDataSize+1,1,hInternet.file);
    687690    *lpdwNumberOfBytesRead = hInternet.nDataLen;
    688691  }
  • trunk/zoo-project/zoo-kernel/ulinet.h

    r921 r944  
    7575   */
    7676  typedef struct {
     77    long code; //!< the last received response code
     78    int hasCacheFile; //!< 1 if we used a cache file
     79    int id; //!< The position of the element in the queue
     80    size_t nDataLen; //!< the length of the downloaded content
     81    size_t nDataAlloc; //!<
    7782    CURL *handle; //!< the CURL handler
    7883    struct curl_slist *header; //!< the headers to send
     
    8489    char *post; //!< the potential POST XML content
    8590    char* cookie; //!< The potential Cookie returned by the server
    86     int hasCacheFile; //!< 1 if we used a cache file
    87     int nDataLen; //!< the length of the downloaded content
    88     int nDataAlloc; //!<
    89     long code; //!< the last received response code
    90     int id; //!< The position of the element in the queue
    9191  } _HINTERNET;
    9292
     
    9595   */
    9696  typedef struct {
     97    int nb; //!< number of element in the queue
    9798    CURLM *handle; //!< the CURLM handler
    9899    _HINTERNET ihandle[MAX_REQ]; //!< individual handlers in the queue
    99100    char *waitingRequests[MAX_REQ]; //!< request in the queue
    100101    char *agent; //!< The User-Agent to use for HTTP request
    101     int nb; //!< number of element in the queue
    102102  } HINTERNET;
    103103
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