Prepares and adds the devices to the given API query response
@param {Object} response JSON representation of the response
@param {String} rootUrl The root URL of the original query.
@param {Object} data The data to include in the response
506592
function prepareData(response, rootUrl, data) {
  if(data.devices) {
    var devices = data.devices;
    for(var device in devices) {
      devices[device].href = rootUrl + '/whereis/transmitter/' + device;
      var radioDecodings = devices[device].radioDecodings;
      for(var cDecoding = 0; cDecoding < radioDecodings.length; cDecoding++) {
        var radioDecoder = radioDecodings[cDecoding].identifier.value;
        radioDecodings[cDecoding].href = rootUrl + '/whatat/receiver/' +
                                         radioDecoder;
      }
    }
    response.devices = devices;
  }
}
586339
@Override
    public void addResponseHeader(String key, String value) {
        this.response.addResponseHeader(key, value);
    }
1172466
function HttpRequest (request, response) {
    this.controller.Debug(7, "Data=[%s]", request.url);
    this.adapter.ProcessData (request, response);
    // processing of http responses is done at adapter level
}
729950
function makeRequest(url, callback) {

  // The JSON file that is loaded should be an array of PageInfo:
  var searchDataRequest = new XMLHttpRequest();
  searchDataRequest.onload = function() {
    callback(JSON.parse(this.responseText));
  };
  searchDataRequest.open('GET', url);
  searchDataRequest.send();
}
752833
def _http_response(self, url, method, data=None, content_type=None,
                       schema=None, **kwargs):
        

        if schema is None:
            schema = self.schema_2

        header = {
            'content-type': content_type or 'application/json',
            'Accept': schema,
        }

        # Token specific part. We add the token in the header if necessary
        auth = self.auth
        token_required = auth.token_required
        token = auth.token
        desired_scope = auth.desired_scope
        scope = auth.scope

        if token_required:
            if not token or desired_scope != scope:
                logger.debug("Getting new token for scope: %s", desired_scope)
                auth.get_new_token()

            header['Authorization'] = 'Bearer %s' % self.auth.token

        if data and not content_type:
            data = json.dumps(data)

        path = url.format(**kwargs)
        logger.debug("%s %s", method.__name__.upper(), path)
        response = method(self.host + path,
                          data=data, headers=header, **self.method_kwargs)
        logger.debug("%s %s", response.status_code, response.reason)
        response.raise_for_status()

        return response
169720
function installHandler(deviceRootUrl) {
  deviceUrl = url.parse(deviceRootUrl);
  //do we need to handle https device root Url?
  if (deviceUrl.protocol !== 'http:') {
    console.error('do not support non-http device url');
    return;
  }
  // TODO: in real production this must be hosted on https
  app.use('/', function(req, res) {
    var parsedUrl = url.parse(req.url);
    var headersCopy = {};
    // create a copy of request headers
    for (attr in req.headers) {
      if (!req.headers.hasOwnProperty(attr)) continue;
      headersCopy[attr] = req.headers[attr];
    }
    deviceUrl.path = req.url;
    var options = {
      uri: deviceUrl,
      method: req.method,
      path: parsedUrl.path,
      headers: headersCopy
    };

    var clientRequest = request(options);
    clientRequest.on('response', function(response) {
      res.statusCode = response.statusCode;
      for (header in response.headers) {
        if (!response.headers.hasOwnProperty(header)) continue;
        res.setHeader(header, response.headers[header]);
      }
      response.pipe(res);
    });
    req.pipe(clientRequest);
  });
}
1171160
function (url) {
    var req = new XMLHttpRequest();

    // Response handler. Check the console for errors.
    var respond = function () {
        if (req.status !== 200) {
          console.warn(req.responseText);
          return;
        }
        // Show the raw response text on page
        xmlOutput.textContent = req.responseText;
        // convert XML to javascript objects
        var json = sdmxmllib.mapSDMXMLResponse(req.responseText);
        // Convert to json and show on page
        jsonOutput.textContent = JSON.stringify(json, null, 2);
    };

    req.open('GET', url);
    // This will return latest version (SDMX-ML 2.1)
    req.setRequestHeader('Accept', 'application/xml');

    req.onreadystatechange = function () {
      if (req.readyState > 3) respond();
    };

    req.onerror = function (err) {
      console.warn(err);
    };

    req.send(null);
  }
1083560
function loadData(dataUrl, jsonEditor) {

    // jQuery getJSON will read the file from a Web resources.
    $.getJSON(dataUrl, function(data) {
    //$.getJSON('data/simple-zoomable-circle.json', function(data) {
        // set data to JSON editor.
        jsonEditor.set(data);
        // update the JSON source code
        $('#jsonstring').html(JSON.stringify(data, null, 2));
        // remove the existing one.
        $('#svgpreview').empty();
        // build the circles...
        var options = {
          "margin":10,
          "diameter":500
        };
        $("#svgpreview").zoomableCircles(options, data);
        //console.log(JSON.stringify(data));
    });
}
405298
private void processRedirectResponse(Response response) throws RuntimeException, JSONException, MalformedURLException {
        // a valid redirect response must contain the Location header.
        ResponseImpl responseImpl = (ResponseImpl)response;
        List<String> locationHeaders = responseImpl.getHeader(LOCATION_HEADER_NAME);

        String location = (locationHeaders != null && locationHeaders.size() > 0) ? locationHeaders.get(0) : null;

        if (location == null) {
            throw new RuntimeException("Redirect response does not contain 'Location' header.");
        }

        // the redirect location url should contain "wl_result" value in query parameters.
        URL url = new URL(location);
        String query = url.getQuery();

        if (query.contains(WL_RESULT)) {
            String result = Utils.getParameterValueFromQuery(query, WL_RESULT);
            JSONObject jsonResult = new JSONObject(result);

            // process failures if any
            JSONObject jsonFailures = jsonResult.optJSONObject(AUTH_FAILURE_VALUE_NAME);

            if (jsonFailures != null) {
                processFailures(jsonFailures);
                listener.onFailure(response, null, null);
                return;
            }

            // process successes if any
            JSONObject jsonSuccesses = jsonResult.optJSONObject(AUTH_SUCCESS_VALUE_NAME);

            if (jsonSuccesses != null) {
                processSuccesses(jsonSuccesses);
            }
        }

        // the rest is handles by the caller
        listener.onSuccess(response);
    }
92454
function ProcessDataChannelsResponse(jsonAnswer) {
    var data = JSON.parse(jsonAnswer);
    data = data.result;

    var channels = [];
    for (var deviceId in data) {
        if (data[deviceId] !== undefined) {
            channels = data[deviceId];
        }
    }

    /**
     * @property channels
     * @type {Array}
     */
    this.channels = channels;
}
114163
function DevicesResponse(jsonAnswer) {
    var data = JSON.parse(jsonAnswer);
    data = data.result.devices;

    var devices = [];
    if (Array.isArray(data)) {
        data.forEach(function (value) {
            devices.push(createDevice(value.key, value.name, value.children));
        });
    }

    /**
     * @property devices
     * @type {Array}
     */
    this.devices = devices;
}
412565
function(dbresult) {
        // start with response header
        var jsonresponse= // validate syntaxe at http://geojsonlint.com/
          {"type":"GeometryCollection"
          ,"device":
            {"type":"Device"
            ,"class":device.class
            ,"model": device.model
            ,"call": device.call
          },"properties":
            {"type":"Properties"
            ,'id'  : query.devid
            ,"name": device.name
            ,'url': devurl
            ,'img': device.img
          }
          ,"geometries":[]             
          };       
     
        for (var idx in dbresult) {
            var pos = dbresult [idx];
            var ptsinfo=util.format ("%s<br>Position:[%s,%s] Speed:%s",pos.date,pos.lon.toFixed(4),pos.lat.toFixed(4),pos.sog.toFixed(1));
            jsonresponse.geometries.push (
                   {'type':'Point'
                    ,'coordinates' :[pos.lon, pos.lat]
                    ,'sog' : pos.sog
                    ,'cog' : pos.cog
                    ,'date' : pos.date.getTime()
                    ,'properties'  :
                        {'type':'Properties'
                        ,"title": ptsinfo 
                    }});
           };
    if (query.jsoncallback === undefined) {
        response.writeHead(200,{"Content-Type": "application/json"});  
        response.write(JSON.stringify(jsonresponse));
    } else {
        response.writeHead(200,{"Content-Type": "text/javascript",'Cache-Control':'no-cache'});  
        var fakescript=query.jsoncallback +'(' + JSON.stringify(jsonresponse) +');';
        response.write (fakescript);
    }      
    response.end(); 
    }
357321
function(json_data){
    bbop_rest_response.json.call(this, json_data);
    //console.log('_is_a', this._is_a);
    this._is_a = 'bbop-response-golr';
    //console.log('_is_a', this._is_a);

    // The setting of:
    //   this._raw (as JSON)
    //   this._raw_string (incoming arg)
    //   this._okay (parsability)
    // are left to the superclass.

    // Cache for repeated calls to success().
    this._success = null;

    // Cache for repeated calls to get_doc* functions.
    // These are non-incremental indices--they are either full formed
    // (the first time they are hit) or they are null.
    this._doc_id2index = null;
    this._doc_index2_id = null;

    // Cache for repeated calls to resolve labels.
    // This cache is incremental--the more it's used the larger it gets.
    this._doc_label_maps = {}; // {<field_1>: <parsed_json_map_1>, ...}

    // For highlight stripping, I just want to compile this once.
    this._hl_regexp = new RegExp("\<\[\^\>\]\*\>", "g");

}
515690
function(response) {
        var chunks = [];

        response.on('data', function(chunk) {
            chunks.push(chunk);
        });

        response.on('end', function() {
            var json = JSON.parse(chunks.join(''));
            this._showOutputInfo(json);
            this._handleOutput(json);
        }.bind(this));
    }
757472
function onResponse( response ) {
		if ( response.statusCode !== 200 ) {
			err = {
				'status': response.statusCode,
				'message': ''
			};
		}
		debug( 'Received a response from query endpoint.' );
		debug( 'Response status: %s.', response.statusCode );
		debug( 'Response headers: %s', JSON.stringify( response.headers ) );

		response.setEncoding( 'utf8' );
		response.on( 'data', onData );
		response.on( 'end', onEnd );
	}
989270
function API(method, url, data, callback) {
    if (typeof callback === 'undefined') {
        callback  = data;
        data  = {};
    }

    url             = this.prepareUrl(url);
    this.callback   = callback || noop;
    this.data       = data;

    this.options          = extend({}, requestOptions);
    this.options.encoding = this.options.encoding || 'utf-8';

    // these particular set of options should be immutable
    this.options.method         = method;
    this.options.uri            = url;
    this.options.followRedirect = false;

    this[method.toLowerCase()]();

    return this;
}
131967
function parseResponse(response) {
  let text;

  if (response && response.content && (typeof response.content === 'string')) {
    text = response.content;
  }

  if (response && response.text && (typeof response.text === 'string')) {
    text = response.text;
  }

  if (!text) {
    console.error('Did not supply any matching response format. Response is:', text);
    return null;
  }

  try {
    const parsedResponse = JSON.parse(text);

    if (
      parsedResponse
      && parsedResponse.data
      && (parsedResponse.data instanceof Object === true)
    ) {
      return parsedResponse.data;
    }
  } catch (err) {
    console.error('Error while parsing JSON', err);
  }

  return null;
}