Changeset 828 for trunk/zoo-project


Ignore:
Timestamp:
May 23, 2017, 1:54:31 PM (2 years ago)
Author:
djay
Message:

Add support for headers definition to requests run from js ZOO-API.

Location:
trunk/zoo-project
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/HISTORY.txt

    r817 r828  
    11Version 1.7.0-dev
     2  * Support headers for GET requests from the js ZOO-API
    23  * Pass all headers listed in the attributes parameter from the
    34  [security] section to the hosts listed in the hosts parameter of the
  • trunk/zoo-project/zoo-api/js/ZOO-api.js

    r625 r828  
    436436   * url - {String} The URL to request.
    437437   * params - {Object} Params to add to the url
     438   * headers - {Object/Array}  A key-value object of headers
    438439   *
    439440   * Returns:
    440441   * {String} Request result.
    441442   */
    442   Get: function(url,params) {
     443    Get: function(url,params,headers) {
    443444    var paramsArray = [];
    444445    for (var key in params) {
     
    466467      url += separator + paramString;
    467468    }
    468     return ZOORequest('GET',url);
     469    if(!(headers instanceof Array)) {
     470        var headersArray = [];
     471        for (var name in headers) {
     472            headersArray.push(name+': '+headers[name]);
     473        }
     474        headers = headersArray;
     475    }
     476    return ZOORequest('GET',url,headers);
    469477  },
    470478  /**
  • trunk/zoo-project/zoo-kernel/service_internal_js.c

    r790 r828  
    934934  }else{
    935935    if(argc==3){
    936       char *body=JSValToChar(cx,&argv[2]);
    937       InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],body,strlen(body),
    938                       INTERNET_FLAG_NO_CACHE_WRITE,0);
    939       processDownloads(&hInternet);
    940       free(body);
     936      if(strncasecmp(method,"GET",3)==0){
     937        header=JSVAL_TO_OBJECT(argv[2]);
     938        if(JS_IsArrayObject(cx,header)){
     939          setHeader(&hInternet,cx,header);
     940        }
     941        InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],NULL,0,
     942                        INTERNET_FLAG_NO_CACHE_WRITE,0);
     943        processDownloads(&hInternet);
     944      }else{
     945        char *body=JSValToChar(cx,&argv[2]);
     946        InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],body,strlen(body),
     947                        INTERNET_FLAG_NO_CACHE_WRITE,0);
     948        processDownloads(&hInternet);
     949        free(body);
     950      }
    941951    }else{
    942952      InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],NULL,0,
  • trunk/zoo-project/zoo-kernel/ulinet.c

    r827 r828  
    185185 * @param proto the protocol requiring the use of a proxy
    186186 */
    187 bool setProxiesForProtcol(CURL* handle,const char *proto){
     187int setProxiesForProtcol(CURL* handle,const char *proto){
    188188#ifdef MSG_LAF_VERBOSE
    189189  fprintf( stderr, "setProxiesForProtocol (do nothing) ...\n" );
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