Make http request
549894
function(request, callback, response_middlewares) {
        var that = this;
        request.finalize(function(err, res) {
            if (err) callback(err, null);
            else that._callResponseMiddlewares(response_middlewares, res, callback);
        });
    }
27292
def _http_call(self, url, method, **kwargs):
        """"""
        logging.debug("Request[{0}]: {1}".format(method, url))
        start_time = datetime.datetime.now()

        logging.debug("Header: {0}".format(kwargs['headers']))
        logging.debug("Params: {0}".format(kwargs['data']))
        response = requests.request(method, url, verify=False, **kwargs)

        duration = datetime.datetime.now() - start_time
        logging.debug("Response[{0:d}]: {1}, Duration: {2}.{3}s.".format(
            response.status_code, response.reason, duration.seconds,
            duration.microseconds))
        return response
1291881
def make_request(self, session, url, **kwargs):
        
        log.debug('Making request: POST %s %s' % (url, kwargs))
        return session.post(url, **kwargs)
494930
def _make_request(self, params, translation_url, headers):
        
        resp = requests.get(translation_url, params=params, headers=headers)
        resp.encoding = "UTF-8-sig"
        result = resp.json()
        return result
1148853
def create_request(version, method, url, headers):
    """"""
    # According to my measurements using b''.join is faster that constructing a
    # bytearray.
    message = []
    message.append('{} {} HTTP/{}\r\n'.format(method, url, version))
    for name, value in headers:
        message.append(name)
        message.append(': ')
        message.append(value)
        message.append('\r\n')
    message.append('\r\n')
    return s2b(''.join(message))
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)
358648
def _request(self, method, body=None, raise_exc=True, headers=None, files=None):
        ''''''
        headers = headers or {}
        if body and 'Content-Type' not in headers:
            headers.update({'Content-Type': 'application/json'})
        response = self._core.session.request(
            method,
            self.uri,
            data=body if not isinstance(body, dict) else None,
            json=body if isinstance(body, dict) else None,
            files=files,
            headers=headers,
            allow_redirects=False,
        )
        nav = self._create_navigator(response, raise_exc=raise_exc)
        if raise_exc and not response:
            raise exc.HALNavigatorError(
                message=response.text,
                status=response.status_code,
                nav=nav,  # may be self
                response=response,
            )
        else:
            return nav
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
951745
def request(self, url, method="get", format="json", data=None,
                expected_status=None, headers=None, use_xpost=True, **options):
        
        if expected_status is None:
            if method == "get":
                expected_status = 200
            elif method == "post":
                expected_status = 201
            else:
                raise ValueError("No expected status supplied and method unknown.")

        if not url.startswith("http"):
            url = "{self.host}/api/v4/{url}".format(**locals())
        if format is not None:
            options = dict({'format': format}, **options)
        options = {field: value for field, value in options.items() if value is not None}
        headers = dict(headers or {}, Authorization="Token {}".format(self.token))
        #headers['Accept-encoding'] = 'gzip'

        if method == "get" and use_xpost:
            # If method is purely GET, we can use X-HTTP-METHOD-OVERRIDE to send our
            # query via POST. This allows for a large number of parameters to be supplied
            assert(data is None)

            headers.update({"X-HTTP-METHOD-OVERRIDE": method})
            data = options
            options = None
            method = "post"

        r = requests.request(method, url, data=data, params=options, headers=headers)

        log.debug(
            "HTTP {method} {url} (options={options!r}, data={data!r},"
            "headers={headers}) -> {r.status_code}".format(**locals())
        )
        return check(r, expected_status=expected_status)
619949
function make_request(params, cb) {

  var options =
  { uri: params.uri
  , method: params.method
  , headers: params.headers
  }

  if (params.body) options.body = params.body
  else options.headers['content-length'] = 0

  debug("making request", options)
  request.make(options, function (error, response, body) {
    cb(error, response)
  })
}
230451
function makeHttpRequest(next) {
  var start = Date.now();

  var timestamp = Date.now();
  var reqBody = 'time * 2 = ' + (timestamp * 2);

  sepia.filter({
    url: /.*/,
    urlFilter: function(url) {
      // disregard the timestamp in the query parameter
      return url.replace(/time\=[0-9]+/, '');
    },
    bodyFilter: function(body) {
      // disregard the timestamp in the request body
      return body.replace(/\= [0-9]+/, '');
    }
  });

  request({
    url: 'http://localhost:1337',
    method: 'POST',
    qs: {
      time: timestamp
    },
    body: reqBody
  }, function(err, data, body) {
    var time = Date.now() - start;

    console.log('FILTERS');
    console.log('  status:', data.statusCode);
    console.log('  body  :', body);
    console.log('  time  :', time);

    common.verify(function() {
      common.shouldBeDynamicallyTimed(time);
    });

    console.log();

    next();
  });
}
479404
def request(self, method, url, *args):
        
        return self.http.request(method, url, *args)
192426
def request(self, uri, method, *args, **kwargs):
        
        if self.timeout:
            kwargs["timeout"] = self.timeout
        kwargs["verify"] = self.verify_ssl
        kwargs.setdefault("headers", kwargs.get("headers", {}))
        kwargs["headers"]["User-Agent"] = self.user_agent
        kwargs["headers"]["Accept"] = "application/json"
        if ("body" in kwargs) or ("data" in kwargs):
            if "Content-Type" not in kwargs["headers"]:
                kwargs["headers"]["Content-Type"] = "application/json"
            elif kwargs["headers"]["Content-Type"] is None:
                del kwargs["headers"]["Content-Type"]
        # Allow subclasses to add their own headers
        self._add_custom_headers(kwargs["headers"])
        resp, body = pyrax.http.request(method, uri, *args, **kwargs)
        if resp.status_code >= 400:
            raise exc.from_response(resp, body)
        return resp, body
1315984
def make_request(url, method='GET', headers=None, timeout=30, **kwargs):
    """"""
    headers = headers or {}
    headers['User-Agent'] = 'treeherder/{}'.format(settings.SITE_HOSTNAME)
    # Work around bug 1305768.
    if 'queue.taskcluster.net' in url:
        headers['x-taskcluster-skip-cache'] = 'true'
    response = requests.request(method,
                                url,
                                headers=headers,
                                timeout=timeout,
                                **kwargs)

    if response.history:
        params = {
            'url': url,
            'redirects': len(response.history),
            'duration': sum(r.elapsed.total_seconds() for r in response.history)
        }
        newrelic.agent.record_custom_event('RedirectedRequest', params=params)

    response.raise_for_status()
    return response
1150616
def make_request(self, session, url, **kwargs):
        
        log.debug('Making request: GET %s %s' % (url, kwargs))
        return session.get(url, **kwargs)
622895
def req(self, meth, url, http_data=''):
        
        self.logger.debug("Making request: %s %s\nBody:%s" % (meth, url, http_data))
        req_method = getattr(requests, meth)
        return (req_method(url,
                           auth=(self.__username, self.__password),
                           data=http_data,
                           headers=({'user-agent': self.user_agent(), 'Accept': 'application/json'})))
208668
def __make_request(self, requests_session, method, url, params, data, headers, certificate):
        
        verify = False
        timeout = self.timeout

        try:  # TODO : Remove this ugly try/except after fixing Java issue: http://mvjira.mv.usa.alcatel.com/browse/VSD-546
            response = requests_session.request(method=method,
                                        url=url,
                                        data=data,
                                        headers=headers,
                                        verify=verify,
                                        timeout=timeout,
                                        params=params,
                                        cert=certificate)
        except requests.exceptions.SSLError:
            try:
                response = requests_session.request(method=method,
                                            url=url,
                                            data=data,
                                            headers=headers,
                                            verify=verify,
                                            timeout=timeout,
                                            params=params,
                                            cert=certificate)
            except requests.exceptions.Timeout:
                return self._did_timeout()

        except requests.exceptions.Timeout:
            return self._did_timeout()

        return response