Write a Request.
552897
def write(self, request):
    """"""
    if FLAGS.sc2_verbose_protocol:
      self._log(" Writing request ".center(60, "-") + "\n")
      self._log_packet(request)
    self._write(request)
135302
def _doRequest(self, request=None, is_file=False, file_xml_uri=''):
		""""""
		if request is None:
			request = []

		if is_file and file_xml_uri:
			url = self._buildFileUrl(file_xml_uri)
		else:
			request = '&'.join(request)
			url = "%s?%s" % (self._buildUrl(), request)

		if self._debug:
			print '[PyFileMaker DEBUG] ', url

		resp = requests.get(
			url = url,
			auth = (self._login, self._password)
		)
		resp.raise_for_status()

		return resp.content
397988
def put(self, endpoint: str, **kwargs) -> dict:
        """"""

        return self._request('PUT', endpoint, **kwargs)
647173
def request(self, method, url, **kwargs):
        

        if "data" in kwargs:
            kwargs["data"] = json.dumps(kwargs["data"])

        kwargs["headers"] = {
            'Content-Type': 'application/json',
            'Authorization': 'token %s' % self.__token__,
        }
        req = make_request(
            method,
            url,
            **kwargs
        )
        self.logger.debug(
            "Request::{}::{}".format(method, url),
            extra={
                "request": kwargs,
                "response": {"headers": req.headers, "code": req.status_code, "data": req.content}
            }
        )
        return req
1106722
def process_request(self, request, response):
        """"""
        self.logger.info('Requested: {0} {1} {2}'.format(request.method, request.relative_uri, request.content_type))
962658
def make_request(self, handle, value, timeout=DEFAULT_TIMEOUT, with_response=True):
        """"""
        try:
            with self:
                _LOGGER.debug("Writing %s to %s with with_response=%s", codecs.encode(value, 'hex'), handle, with_response)
                self._conn.writeCharacteristic(handle, value, withResponse=with_response)
                if timeout:
                    _LOGGER.debug("Waiting for notifications for %s", timeout)
                    self._conn.waitForNotifications(timeout)
        except btle.BTLEException as ex:
            _LOGGER.debug("Got exception from bluepy while making a request: %s", ex)
            raise
216745
def request(self, path, method='GET', params=None):
        """"""
        if params is None: params = {}
        url = urljoin(self.endpoint, path)

        headers = {
            'Accept': 'application/json',
            'Authorization': 'AccessKey ' + self.access_key,
            'User-Agent': self.user_agent,
            'Content-Type': 'application/json'
        }

        if method == 'DELETE':
            response = requests.delete(url, verify=True, headers=headers, data=json.dumps(params))
        elif method == 'GET':
            response = requests.get(url, verify=True, headers=headers, params=params)
        elif method == 'PATCH':
            response = requests.patch(url, verify=True, headers=headers, data=json.dumps(params))
        elif method == 'POST':
            response = requests.post(url, verify=True, headers=headers, data=json.dumps(params))
        elif method == 'PUT':
            response = requests.put(url, verify=True, headers=headers, data=json.dumps(params))
        else:
            raise ValueError(str(method) + ' is not a supported HTTP method')

        if response.status_code in self.__supported_status_codes:
            response_text = response.text
        else:
            response.raise_for_status()

        return response_text
448072
def handle_request(self):
        """"""
        try:
            request, client_address = self.get_request()
        except socket.error:
            return

        if self.verify_request(request, client_address):
            self.requests.put((request, client_address))
213229
def _request(self, **kwargs):
        
        '''  '''
        
        response = None
        error = ''
        code = 0
        
    # send request
        from requests import request
        try:
            response = request(**kwargs)
        # handle response
            if self.handle_response:
                response, error, code = self.handle_response(response)
            else:
                code = response.status_code
    # handle errors
        except Exception as err:
            from requests import Request
            request_object = Request(**kwargs)
            try:
                request_details = self.handle_requests(request_object)
                error = request_details['error']
            except:
                error = str(err)
                
        return response, error, code
389174
def _request(self, uri, params=None, postParams=None, verb='GET'):
        """"""
        return getattr(requests, verb.lower())(self.url + uri, params=params, data=postParams, stream=True)
1252051
def _make_request(self, conf, post_params={}):
        """"""
        endpoint, requires_auth = conf

        # setup the url and the request objects
        url = '%s%s.php' % (self.api_url, endpoint)
        log.debug('Setting url to %s' % url)
        request = urllib2.Request(url)

        # tack on authentication if needed
        log.debug('Post params: %s' % post_params)
        if requires_auth:
            post_params.update({
                'user': self.username,
                'pass': self.password
            })

        # url encode all parameters
        data = urlencode(post_params).encode('utf-8')

        # gimme some bitcoins!
        try:
            log.debug('Requesting data from %s' % url)
            response = urllib2.urlopen(request, data)
            return json.loads(response.read())
        except urllib2.URLError as e:
            log.debug('Full error: %s' % e)
            if hasattr(e, 'reason'):
                self.log.error('Could not reach host. Reason: %s' % e.reason)
            elif hasattr(e, 'code'):
                self.log.error('Could not fulfill request. Error Code: %s' % e.code)
            return None
137240
def write(self, out):
        """"""
        out.write_short(self.priority)
        out.write_short(self.weight)
        out.write_short(self.port)
        out.write_name(self.server)
1136530
def write(url, content, **args):
    """"""
    with HTTPResource(url, **args) as resource:
        resource.write(content)
358790
def _send_request(self, request, **kwargs):
        """"""
        log.debug(LOG_CHECK, "Send request %s with %s", request, kwargs)
        log.debug(LOG_CHECK, "Request headers %s", request.headers)
        self.url_connection = self.session.send(request, **kwargs)
        self.headers = self.url_connection.headers
        self._add_ssl_info()
1281415
def perform_request(self, request_type, *args, **kwargs):
        
        # create a request
        req = api_request(request_type, *args, **kwargs)

        # send it
        res = self.send_request(req)

        return res
1299192
def WriteFlowRequests(self, requests):
    """"""
    flow_processing_requests = []

    for request in requests:
      if (request.client_id, request.flow_id) not in self.flows:
        raise db.AtLeastOneUnknownFlowError([(request.client_id,
                                              request.flow_id)])

    for request in requests:
      key = (request.client_id, request.flow_id)
      request_dict = self.flow_requests.setdefault(key, {})
      request_dict[request.request_id] = request.Copy()
      request_dict[request.request_id].timestamp = rdfvalue.RDFDatetime.Now()

      if request.needs_processing:
        flow = self.flows[(request.client_id, request.flow_id)]
        if flow.next_request_to_process == request.request_id:
          flow_processing_requests.append(
              rdf_flows.FlowProcessingRequest(
                  client_id=request.client_id,
                  flow_id=request.flow_id,
                  delivery_time=request.start_time))

    if flow_processing_requests:
      self.WriteFlowProcessingRequests(flow_processing_requests)
1251360
def request(self, action):
    """"""
    ev = threading.Event()
    first = False
    with self.__lock:
      if len(self.__events) == 0:
        first = True
      self.__events.append(ev)
    if first:
      action()
    return ev