Perform an HTTP request
344615
def request(method, path, params = {}, options = {})

      raise AirbrakeError.new('API Token cannot be nil') if @auth_token.nil?
      raise AirbrakeError.new('Account cannot be nil') if @account.nil?

      response = connection(options).run_request(method, nil, nil, nil) do |request|
        case method
        when :delete, :get
          request.url(path, params.merge(:auth_token => @auth_token))
        when :post, :put
          request.url(path, :auth_token => @auth_token)
          request.body = params unless params.empty?
        end
      end
      response.body
    end
479404
def request(self, method, url, *args):
        
        return self.http.request(method, url, *args)
925995
def request(http_method, data={}, url="")
      final_url = @options[:base_url] << url
        begin
          case http_method
              when :get
                response = Curl.get(final_url, data) do |http|
                  http.headers['x-api-key'] = @options[:api_key]
                  http.headers['Accept'] = 'application/json'
                end
          end
        rescue Curl::Err::HostResolutionError
          raise Fulfil::HostResolutionError, "Invalid Subdomain"
        end
      parse_response response
    end
132708
def request(http_method, path, body = '', headers = {})
      puts "#{http_method}: #{path} - [#{body}]" if @http_debug
      @request_client.request(http_method, path, body, headers)
    end
489827
function request(url, options, callback)
{
  var connection;

  if (typeof options == 'function')
  {
    callback = options;
    options  = {};
  }

  connection = hyperquest(url, options, once(function(error, response)
  {
    if (error)
    {
      callback(error, response);
      return;
    }

    // set body
    response.body = '';

    // accumulate response body
    response.on('data', function(data)
    {
      response.body += data.toString();
    });

    response.on('end', function()
    {
      callback(null, response);
    });
  }));

  return connection;
}
172182
def request( self, url, method='get',
			decode=None, encode=None, data=None,
			headers=None, raise_for=dict(), queue_lines=None ):
		''''''
		if self.debug_requests:
			url_debug = _dump_trunc(url)
			log.debug('HTTP request: {} {} (h: {}, enc: {}, dec: {}, data: {!r})'.format(
				method, url_debug, headers, encode, decode, _dump_trunc(data) ))

		timeout = HTTPTimeout(**self.request_io_timeouts)
		req_headers = {'User-Agent': 'txU1'}

		if data is not None:
			if encode == 'files':
				boundary = os.urandom(16).encode('hex')
				req_headers['Content-Type'] = 'multipart/form-data; boundary={}'.format(boundary)
				data = MultipartDataSender(data, boundary)
				if not callable(headers): yield data.calculate_length()
				else:
					body = io.BytesIO()
					yield data.calculate_length(body)
					headers = headers(url, method, body.getvalue(), 'multipart/form-data')
			else:
				if encode is None:
					if isinstance(data, types.StringTypes): data = io.BytesIO(data)
				elif encode == 'form':
					req_headers['Content-Type'] = 'application/x-www-form-urlencoded'
					data = io.BytesIO(urllib.urlencode(data))
				elif encode == 'json':
					req_headers['Content-Type'] = 'application/json'
					data = io.BytesIO(json.dumps(data))
				else: raise ValueError('Unknown request encoding: {}'.format(encode))
				if callable(headers):
					data.seek(0)
					headers = headers(url, method, data.read(), req_headers.get('Content-Type'))
				data = FileBodyProducer(data)
		elif callable(headers): headers = headers(url, method, '', None)

		# Passed "headers" should be allowed to be modified by body_hash()
		for k, v in (headers or dict()).viewitems():
			req_headers[force_bytes(k)] = force_bytes(v)
		url, method = it.imap(force_bytes, [url, method.lower()])

		if decode == 'json': req_headers.setdefault('Accept', 'application/json')
		elif decode is not None:
			raise ValueError('Unknown response decoding method: {}'.format(decode))

		res_deferred = first_result( timeout,
			self.request_agent.request( method.upper(), url,
				Headers(dict((k,[v]) for k,v in req_headers.viewitems())), data ) )
		code = res_body = None
		try:
			res = yield res_deferred
			code = res.code
			if code == http.NO_CONTENT: defer.returnValue(None)
			if code not in [http.OK, http.CREATED]:
				if self.debug_requests:
					res_body = defer.Deferred()
					res.deliverBody(DataReceiver(res_body, timer=timeout, allow_loss=True))
					res_body = yield first_result(timeout, res_body)
					log.debug('HTTP error response body: {!r}'.format(res_body))
				raise ProtocolError(code, res.phrase)

			res_body = defer.Deferred()
			res.deliverBody(DataReceiver(res_body, timer=timeout))
			res_body = yield first_result(timeout, res_body)

			if self.debug_requests:
				log.debug( 'HTTP request done ({} {}): {} {} {}, body_len: {}'\
					.format(method, url_debug, code, res.phrase, res.version, len(res_body)) )
			defer.returnValue(json.loads(res_body) if decode is not None else res_body)

		except ( timeout.ActivityTimeout, TimeoutError,
				ResponseFailed, RequestNotSent, RequestTransmissionFailed ) as err:
			if isinstance(err, timeout.ActivityTimeout):
				if not res_deferred.called: res_deferred.cancel()
				if res_body and not res_body.called: res_body.cancel()
			if self.debug_requests:
				log.debug(
					'HTTP transport (underlying protocol) error ({} {}): {}'\
					.format(method, url_debug, err.message or repr(err.args)) )
			raise UnderlyingProtocolError(err)

		except ProtocolError as err:
			if self.debug_requests:
				log.debug(
					'HTTP request handling error ({} {}, code: {}): {}'\
					.format(method, url_debug, code, err.message) )
			raise raise_for.get(code, ProtocolError)(code, err.message)

		except RequestGenerationFailed as err:
			err[0][0].raiseException()

		finally: timeout.state_finished()
1321277
def request(method, uri, *args, **kwargs):
    
    req_method = req_methods[method.upper()]
    raise_exception = kwargs.pop("raise_exception", True)
    raw_content = kwargs.pop("raw_content", False)
    kwargs["headers"] = kwargs.get("headers", {})
    http_log_req(method, uri, args, kwargs)
    data = None
    if "data" in kwargs:
        # The 'data' kwarg is used when you don't want json encoding.
        data = kwargs.pop("data")
    elif "body" in kwargs:
        if "Content-Type" not in kwargs["headers"]:
            kwargs["headers"]["Content-Type"] = "application/json"
        data = json.dumps(kwargs.pop("body"))
    if data:
        resp = req_method(uri, data=data, **kwargs)
    else:
        resp = req_method(uri, **kwargs)
    if raw_content:
        body = resp.content
    else:
        try:
            body = resp.json()
        except ValueError:
            # No JSON in response
            body = resp.content
    http_log_resp(resp, body)
    if resp.status_code >= 400 and raise_exception:
        raise exc.from_response(resp, body)
    return resp, body
1345437
def _http_request(self, api, data, headers=None):
        
        if not headers:
            headers = {'Content-Type': 'application/json'}
        if not self._token_valid:
            self._token = self.get_token(self._app_name, self._username, self._password)
        response = requests.post(self._base_url + '/' + api, data=json.dumps(data),
                                 headers=headers)
        # raise an exception if the status was not 200
        logger.debug(json.dumps(data))
        logger.debug(response.text)
        response.raise_for_status()
        return response
755232
def request(http_method, uri, options={})
      response = self.class.__send__(http_method, uri, options.merge(basic_auth))
      # Add some logger.debug here ...
      response
    end
1075160
def _request(self, method, path, params=None):
        """"""
        url = self._base_url + path

        try:
            if method == 'GET':
                response = requests.get(url, timeout=TIMEOUT)
            elif method == "POST":
                response = requests.post(url, params, timeout=TIMEOUT)
            elif method == "PUT":
                response = requests.put(url, params, timeout=TIMEOUT)
            elif method == "DELETE":
                response = requests.delete(url, timeout=TIMEOUT)

            if response:
                return response.json()
            else:
                return {'status': 'error'}
        except requests.exceptions.HTTPError:
            return {'status': 'error'}
        except requests.exceptions.Timeout:
            return {'status': 'offline'}
        except requests.exceptions.RequestException:
            return {'status': 'offline'}
572932
def perform_api_request(
        self,
        url,
        method='POST',
        headers=None,
        body=None,
        **kwargs
    ):
        '''
        
        '''
        assert method in ('GET', 'POST')
        if method == 'GET':
            response = self._perform_get(url, headers=headers, **kwargs)
        elif method == 'POST':
            response = self._perform_post(url, headers=headers, data=body, **kwargs)
        return response
1055391
def request(self, url, method, body=None, headers=None, **kwargs):
        """"""

        content_type = kwargs.pop('content_type', None) or 'application/json'
        headers = headers or {}
        headers.setdefault('Accept', content_type)

        if body:
            headers.setdefault('Content-Type', content_type)

        headers['User-Agent'] = self.USER_AGENT

        resp = requests.request(
            method,
            url,
            data=body,
            headers=headers,
            verify=self.verify_cert,
            timeout=self.timeout,
            **kwargs)

        return resp, resp.text
35390
def make_request(call, url)
      request              = Net::HTTP.new(url.host, url.port)
      request.read_timeout = 30
      request.use_ssl      = true

      response = request.start { |http| http.request(call) }
      JSON.parse(response.body)
    end
1055420
def request(self, method, resource, params=None):
        

        url = self.get_url(resource, params)

        # headers

        headers = {
            'Content-Type': 'application/json'
        }

        auth = requests.auth.HTTPBasicAuth(self.username, self.password)

        # request

        log.info('Request to %s. Data: %s' % (url, params))

        response = requests.request(method, url, data=json.dumps(params), headers=headers, auth=auth)
        response.raise_for_status()

        # response

        log.info('Response from %s: %s' % (url, response.text))
        content = response.json()

        self.parse_status(content.get('status'))

        return content
1198411
def build_http_request(klass, path, params = nil, body = nil)
      path += '?' + URI.encode_www_form(params) unless params.nil?
      req = klass.new(path)
      req.body = URI.encode_www_form(body) unless body.nil?
      Etcd::Log.debug("Built #{klass} path:'#{path}'  body:'#{req.body}'")
      req
    end
1215484
def _request(self, path, method, body=None):
        """"""
        url = '/'.join([_SERVER, path])
        (resp, content) = _HTTP.request(url, method,
                                        headers=self._headers, body=body)

        content_type = resp.get('content-type')
        if content_type and content_type.startswith('application/json'):
            content = json.loads(content.decode('UTF-8'))

        return (resp, content)
1291881
def make_request(self, session, url, **kwargs):
        
        log.debug('Making request: POST %s %s' % (url, kwargs))
        return session.post(url, **kwargs)