simple synchronous rest get call
13101
private static String syncRestNativeCall(final String purl) {
    final XMLHttpRequest xmlHttp = Browser.getWindow().newXMLHttpRequest();
    xmlHttp.open("GET", purl, false); // false for synchronous request
    xmlHttp.send();
    return xmlHttp.getResponseText();
  }
807208
def fetch(max_wait_time, min_bytes, topic_fetches)
      ensure_connected
      req = FetchRequest.new( request_common(:fetch),
                                REPLICA_ID,
                                max_wait_time,
                                min_bytes,
                                topic_fetches) 
      send_request(req)
      read_response(FetchResponse)
    end
70186
def _request_get(self, path, params=None, json=True, url=BASE_URL):
        """"""
        url = urljoin(url, path)
        headers = self._get_request_headers()

        response = requests.get(url, params=params, headers=headers)
        if response.status_code >= 500:

            backoff = self._initial_backoff
            for _ in range(self._max_retries):
                time.sleep(backoff)
                backoff_response = requests.get(
                    url, params=params, headers=headers,
                    timeout=DEFAULT_TIMEOUT)
                if backoff_response.status_code < 500:
                    response = backoff_response
                    break
                backoff *= 2

        response.raise_for_status()
        if json:
            return response.json()
        else:
            return response
48312
def _get(self, url, **kw):
        '''
        
        '''
        headers = kw.pop('headers', {})
        headers.setdefault('Content-Type', 'application/json')
        headers.setdefault('Accept', 'application/json')
        headers.setdefault('Authorization', self.AUTHORIZATION_HEADER)
        kw['headers'] = headers
        resp = self.session.get(url, **kw)
        self._raise_for_status(resp)
        return resp
574451
def get_rest_api():
    
    assert _has_local_install

    url=[]
    ok = _run_st(['geturl', '--api'], lines=url)
    if not ok:
        raise ChildProcessError('streamtool geturl')
    return url[0]
406856
def json_call(cls, method, url, **kwargs):
        
        # retrieve api key if needed
        empty_key = kwargs.pop('empty_key', False)
        send_key = kwargs.pop('send_key', True)
        return_header = kwargs.pop('return_header', False)
        try:
            apikey = cls.get('apirest.key')
            if not apikey and not empty_key:
                cls.echo("No apikey found for REST API, please use "
                         "'gandi setup' command")
                sys.exit(1)
            if send_key:
                if 'headers' in kwargs:
                    kwargs['headers'].update({'X-Api-Key': apikey})
                else:
                    kwargs['headers'] = {'X-Api-Key': apikey}
        except MissingConfiguration:
            if not empty_key:
                return []
        # make the call
        cls.debug('calling url: %s %s' % (method, url))
        cls.debug('with params: %r' % kwargs)
        try:
            resp, resp_headers = JsonClient.request(method, url, **kwargs)
            cls.dump('responded: %r' % resp)
            if return_header:
                return resp, resp_headers
            return resp
        except APICallFailed as err:
            cls.echo('An error occured during call: %s' % err.errors)
            sys.exit(1)
530073
def get(self, relpath=None, params=None):
    
    for retry in xrange(self.retries + 1):
      if retry:
        time.sleep(self.retry_sleep)
      try:
        return self.invoke("GET", relpath, params)
      except (socket.error, urllib2.URLError) as e:
        if "timed out" in str(e).lower():
          log_message = "Timeout issuing GET request for %s." \
              % (self._join_uri(relpath), )
          if retry < self.retries:
            log_message += " Will retry."
          else:
            log_message += " No retries left."
          LOG.warn(log_message, exc_info=True)
        else:
          raise
    else:
      raise e
24288
def _handle_get(self, request):
        # type: (Get) -> CallbackResponses
        """"""
        data = self._block

        for i, endpoint in enumerate(request.path[1:]):
            try:
                data = data[endpoint]
            except KeyError:
                if hasattr(data, "typeid"):
                    typ = data.typeid
                else:
                    typ = type(data)
                raise UnexpectedError(
                    "Object %s of type %r has no attribute %r" % (
                        request.path[:i+1], typ, endpoint))
        # Important to serialize now with the lock so we get a consistent set
        serialized = serialize_object(data)
        ret = [request.return_response(serialized)]
        return ret
1362498
def sync_fetch(request, method, default_headers=None,
               httpclient=None, **kwargs):
    
    updated_request = make_request(request, method, default_headers, **kwargs)
    if not httpclient:
        httpclient = HTTPClient()
    rsp = httpclient.fetch(updated_request)
    return parse_response(rsp)
256443
def get(url, parameters = {}, skip_status_check = false)
      response = connection.get("#{api_endpoint}#{url}", parameters)
      on_complete(response) unless skip_status_check
      response
    end
660335
def rest_put(url, data, timeout, show_error=False):
    ''''''
    try:
        response = requests.put(url, headers={'Accept': 'application/json', 'Content-Type': 'application/json'},\
                                data=data, timeout=timeout)
        return response
    except Exception as exception:
        if show_error:
            print_error(exception)
        return None
290823
def json_request(endpoint, verb='GET', session_options=None, **options):
    
    req = functools.partial(_request, endpoint, verb, session_options,
                            json=True, **options)
    return _run_in_fresh_loop(req)
1120448
def rest_put(url, data, timeout):
    ''''''
    try:
        response = requests.put(url, headers={'Accept': 'application/json', 'Content-Type': 'application/json'},\
                                data=data, timeout=timeout)
        return response
    except Exception as e:
        print('Get exception {0} when sending http put to url {1}'.format(str(e), url))
        return None
1340983
function getStatus(url, callback) {
  var client = new HttpClient(url);
  var executor = new Executor(client);
  var command = new Command(CommandName.GET_SERVER_STATUS);
  executor.execute(command, function(err, responseObj) {
    if (err) return callback(err);
    try {
      checkResponse(responseObj);
    } catch (ex) {
      return callback(ex);
    }
    callback(null, responseObj['value']);
  });
}
1172814
def getJson(cls, url, method='GET', headers={}, data=None, socket=None, timeout=120):
        
        if not 'Content-Type' in headers:
            headers['Content-Type'] = ['application/json']

        body = yield cls().getBody(url, method, headers, data, socket, timeout)

        defer.returnValue(json.loads(body))
656020
def rest_post(url, data, timeout, show_error=False):
    ''''''
    try:
        response = requests.post(url, headers={'Accept': 'application/json', 'Content-Type': 'application/json'},\
                                 data=data, timeout=timeout)
        return response
    except Exception as exception:
        if show_error:
            print_error(exception)
        return None
1147457
def _rest(url, req, data=None):
    """"""
    if url.upper().startswith("HTTPS"):
        print("Secure connection required: Please use HTTPS or https")
        return ""

    req = req.upper()
    if req != "GET" and req != "PUT" and req != "POST" and req != "DELETE":
        return ""

    status, body = _api_action(url, req, data)
    if (int(status) >= 200 and int(status) <= 226):
        return body
    else:
        return body