Low-level request interface to mite. Takes a HTTP request scheme (lower
        case!), a URL to request (relative), and optionally data to add to the
        request. Either returns the JSON body of the request or raises a 
        HttpException.
421483
def request(self, scheme, url, data=None, params=None):
        
        url = self.url.format(self.team, url)
        headers = {
            "X-MiteApikey": self.api_key,
            "User-Agent":
                "mite Python wrapper: https://github.com/port-zero/mite",
            "Content-Type": "application/json",
        }
        # this is a nice little hack to make the API nicer
        # we pass the scheme as string, but have it as attributes in requests
        fn = requests.__getattribute__(scheme)

        res = fn(url, headers=headers, json=data, params=params)

        if res.status_code >= 300:
            self._raise_exception(res.status_code)

        if not res.content:
            return None

        try:
            return res.json()
        except ValueError:
            return res.content
671993
def _http_request(url,
                  headers=None,
                  data=None):
    '''
    
    '''
    if not headers:
        headers = _get_headers()
    session = requests.session()
    log.debug('Querying %s', url)
    req = session.post(url,
                       headers=headers,
                       data=salt.utils.json.dumps(data))
    req_body = req.json()
    ret = _default_ret()
    log.debug('Status code: %d', req.status_code)
    log.debug('Response body:')
    log.debug(req_body)
    if req.status_code != 200:
        if req.status_code == 500:
            ret['comment'] = req_body.pop('message', '')
            ret['out'] = req_body
            return ret
        ret.update({
            'comment': req_body.get('error', '')
        })
        return ret
    ret.update({
        'result': True,
        'out': req.json()
    })
    return ret
1120855
def send(url, data):
    
    validate(data)

    return requests.post(url, json=data)
714656
def send_request(url, method, data, 
	args, params, headers, cookies, timeout, is_json, verify_cert):
	
	## Parse url args
	for p in args:
		url = url.replace(':' + p, str(args[p]))

	try:
		if data:
			if is_json:
				headers['Content-Type'] = 'application/json'
				data = json.dumps(data)

			request = requests.Request(
				method.upper(), url, data=data, params=params, 
				headers=headers, cookies=cookies
			)
		else:
			request = requests.Request(
				method.upper(), url, params=params, headers=headers, 
				cookies=cookies
			)

		## Prepare and send HTTP request.
		session = requests.Session()
		session.verify = verify_cert
		r = session.send(request.prepare(), timeout=timeout)
		session.close()

	except requests.exceptions.Timeout:
		return {
			'data': {}, 
			'cookies': CookieJar(),
			'content_type': '', 
			'status': 0, 
			'is_json': False,
			'timeout': True
		}

	try:
		content_type = r.headers.get('Content-Type', 'application/json')
		response = r.json()
		isjson = True
		
	except json.decoder.JSONDecodeError:
		content_type = r.headers.get('Content-Type', 'text/html')
		response = r.text
		isjson = False

	return {
		'data': response,
		'cookies': r.cookies,
		'content_type': content_type, 
		'status': r.status_code,
		'is_json': isjson,
		'timeout': False
	}
274641
def _make_request(self, suburl):
        
        url = "{}/{}".format(self.API_BASE_URL, suburl)
        response = self.session.get(url)
        response.raise_for_status()
        return response.json()
460650
def request(self, host, handler, request_body, verbose):
        
        headers = {'User-Agent': self.user_agent,
                   'Content-Type': 'text/xml',
                   }
        url = self._build_url(host, handler)
        kwargs = {}
        if StrictVersion(requests.__version__) >= StrictVersion('0.8.8'):
            kwargs['verify']=True
        else:
            if self.use_https:
                warnings.warn('using https transport but no certificate '
                              'verification. (Hint: upgrade requests package.)')
        try:
            resp = requests.post(url, data=request_body, headers=headers,
                                 **kwargs)
        except ValueError:
            raise
        except Exception:
            raise # something went wrong
        else:
            try:
                resp.raise_for_status()
            except requests.RequestException as e:
                raise xmlrpc.ProtocolError(url, resp.status_code, 
                                                        str(e), resp.headers)
            else:
                return self.parse_response(resp)
348146
def request(method, uri, data: nil, headers: {}, **kwargs)
      request = Request.new(
        headers: default_headers.merge(headers),
        **kwargs,
        method: method,
        uri: join(uri),
        data: data
      )

      ret = cache.call(request) {|req| adapter.call(req) }
      ret.then do |response|
        if !response.errored?
          process response
        else
          raise ResponseError.from_code(response)
        end
      end
    end
252032
def http_request(url)
      url = URIParser.new(url).with_scheme

      CLI.put_header(url)
      CLI.log "Beginning HTTP request for #{url}"
      response = HTTParty.get(url, headers: { "User-Agent" => "news-scraper-#{NewsScraper::VERSION}" })

      raise ResponseError.new(
        error_code: response.code,
        message: response.message,
        url: url
      ) unless response.code == 200

      CLI.log "#{response.code} - #{response.message}. Request successful for #{url}"
      CLI.put_footer

      if block_given?
        yield response
      else
        response
      end
    end
775196
def _json_request(self, method, path, data):
        

        response = self._request(method, path, data=data)
        _raise_for_status(response)
        if len(response.data) > 0:
            return _json_from_response(response)
        return response.data
448139
def request(*args)
      response = make_request(*args)
      # binding.pry unless response.kind_of?(Net::HTTPSuccess)
      raise HTTPError, response unless response.is_a?(Net::HTTPSuccess)
      response
    end
1308861
async def request(
            self,
            method: str,
            endpoint: str,
            *,
            base_url: str = API_URL_SCAFFOLD,
            headers: dict = None,
            params: dict = None,
            json: dict = None) -> dict:
        """"""
        if not headers:
            headers = {}
        headers.update({'Content-Type': 'application/json'})

        if not params:
            params = {}

        if self._api_key:
            params.update({'key': self._api_key})

        url = '{0}/{1}'.format(base_url, endpoint)
        async with self.websession.request(method, url, headers=headers,
                                           params=params, json=json) as resp:
            data = await resp.json(content_type=None)
            _raise_on_error(data)
            return data
1233763
def _request(self, url, params=None):
        

        response = get(url, params=params, headers=self.headers, timeout=30)

        if response.status_code != 200:
            raise APIError('Request to {} returned {}'.format(response.url, response.status_code))

        response = response.json()

        error_text = response['service_meta']['error_text']
        if error_text:
            raise APIError(error_text)

        return response
277866
def request(self, method, uri, **kwargs):
        

        response = make_tm_request(method, uri, auth=self.auth, **kwargs)

        if method == "DELETE" or response.status == 204:
            return response, {}
        else:
            return response, json.loads(response.content.decode("utf-8"))
1094307
def request(self, method, url, params=None, data=None, headers=None, auth=None,
                timeout=None, allow_redirects=False):
        
        raise TwilioException('HttpClient is an abstract class')
448875
def request(method, url, body=nil) # :nodoc:

      unless ['/', ''].include?(URI::parse(url).path)
        setup_oauth_token
      end

      begin
        raw = connection(current_options.merge({url: url})).send(method) do |req|
          if [:post, :put].include?(method.to_sym) && !body.blank?
            req.body = PMP::CollectionDocument.to_persist_json(body)
          end
        end
      rescue Faraday::Error::ResourceNotFound => not_found_ex
        if (method.to_sym == :get)
          raw = OpenStruct.new(body: nil, status: 404)
        else
          raise not_found_ex
        end
      end

      # may not need this, but remember how we made this response
      PMP::Response.new(raw, {method: method, url: url, body: body})
    end
594491
def send_http_request_with_json(context, method):
    
    safe_add_http_request_context_to_behave_context(context)
    context.http_request_context.body_params = json.loads(context.text)
    context.http_request_context.renderer = JSONRenderer()
    send_http_request(context, method)
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)