Changeset 834


Ignore:
Timestamp:
Jun 20, 2017, 9:38:47 AM (8 years ago)
Author:
djay
Message:

Fix issue with cookie headers in ulinet (cf. https://lists.osgeo.org/pipermail/zoo-discuss/2017-May/001622.html).

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

Legend:

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

    r828 r834  
    7070/**
    7171 * In case of presence of "Set-Cookie" in the headers red, store the cookie
    72  * identifier in CCookie
     72 * identifier in cookie
    7373 *
    7474 * @param buffer the buffer to read
     
    7777 * @param data the _HINTERNET structure to write in
    7878 * @return the size red, -1 if buffer is NULL
    79  * @see CCookie
     79 * @see cookie
    8080 */
    8181size_t header_write_data(void *buffer, size_t size, size_t nmemb, void *data){
     
    8989        ;
    9090#endif
     91    tmp=strtok(buffer,";");
     92    int cnt=0;
    9193    _HINTERNET *psInternet=(_HINTERNET *)data;
    92     tmp=strtok(buffer,";");
    93     if(tmp!=NULL){
    94       sprintf(CCookie[psInternet->id],"%s",tmp);
     94    if(tmp!=NULL && psInternet!=NULL){
     95      psInternet->cookie=(char*)malloc(sizeof(char)*(strlen(tmp)+1));
     96      sprintf(psInternet->cookie,"%s",tmp);
    9597    }
    9698  }
     
    334336    if(handle.url!=NULL)
    335337      free(handle.url);
    336     free(handle.mimeType);
    337     handle.mimeType = NULL;
     338    if(handle.mimeType!=NULL)
     339      free(handle.mimeType);
     340    if(handle.cookie!=NULL)
     341      free(handle.cookie);
    338342  }
    339343  if(handle0->handle)
     
    365369  hInternet->ihandle[hInternet->nb].url = NULL;
    366370  hInternet->ihandle[hInternet->nb].mimeType = NULL;
     371  hInternet->ihandle[hInternet->nb].cookie = NULL;
    367372  hInternet->ihandle[hInternet->nb].nDataLen = 0;
    368373  hInternet->ihandle[hInternet->nb].id = hInternet->nb;
     
    370375  hInternet->ihandle[hInternet->nb].pabyData = NULL;
    371376  hInternet->ihandle[hInternet->nb].post = NULL;
    372 
     377 
    373378  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_COOKIEFILE, "ALL");
    374379#ifndef TIGER
     
    474479
    475480/**
    476  * Initialize the CCookie for a specific index (hInternet.nb)
    477  *
    478  * @param hInternet the HINTERNET structure to know the CCookie index to reset
     481 * Initialize the cookie for a specific index (hInternet.nb)
     482 *
     483 * @param hInternet the HINTERNET structure to know the cookie index to reset
    479484 * @return 1
    480485 * @see HINTERNET
    481486 */
    482487int freeCookieList(HINTERNET hInternet){
    483   memset(&CCookie[hInternet.nb][0],0,1024);
     488  if(hInternet.ihandle[hInternet.nb].cookie)
     489    free(hInternet.ihandle[hInternet.nb].cookie);
     490  hInternet.ihandle[hInternet.nb].cookie=NULL;
    484491#ifndef TIGER
    485492  curl_easy_setopt(hInternet.ihandle[hInternet.nb].handle, CURLOPT_COOKIELIST, "ALL");
     
    530537  }
    531538
    532   CCookie[hInternet.id][0]=0;
    533 
    534539  if( *lpdwNumberOfBytesRead < dwDataSize )
    535540      return 0;
  • trunk/zoo-project/zoo-kernel/ulinet.h

    r817 r834  
    5454#define MAX_REQ 50
    5555
    56 #ifdef _ULINET
    57 static char CCookie[MAX_REQ][1024];
    58 #else
    59 /**
    60  * The cookies found
    61  */
    62 extern char CCookie[MAX_REQ][1024];
    63 #endif
    64 
    6556#ifdef __cplusplus
    6657extern "C" {
     
    8879    char *mimeType; //!< the mimeType returned by the server
    8980    char *post; //!< the potential POST XML content
     81    char* cookie; //!< The potential Cookie returned by the server
    9082    int hasCacheFile; //!< 1 if we used a cache file
    9183    int nDataLen; //!< the length of the downloaded content
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