Create a new request session.
767795
def new_request_session(config, cookies):
    """"""
    session = requests.Session()
    if cookies:
        session.cookies = cookies
    session.max_redirects = config["maxhttpredirects"]
    session.headers.update({
        "User-Agent": config["useragent"],
    })
    if config["cookiefile"]:
        for cookie in cookies.from_file(config["cookiefile"]):
            session.cookies = requests.cookies.merge_cookies(session.cookies, cookie)
    return session
753609
def _create_session(self):
        
        logger.debug("Create new phantomjs web driver")
        self.driver = webdriver.PhantomJS(desired_capabilities=self.dcap,
                                          **self.driver_args)
        self.set_cookies(self.current_cookies)
        self.driver.set_window_size(1920, 1080)
891380
def _build_request_factory(cls, session: AppSession):
        '''
        '''
        def request_factory(*args, **kwargs):
            request = session.factory.class_map['Request'](*args, **kwargs)

            user_agent = session.args.user_agent or session.default_user_agent

            request.fields['User-Agent'] = user_agent

            if session.args.referer:
                request.fields['Referer'] = session.args.referer

            for header_string in session.args.header:
                request.fields.parse(header_string)

            if session.args.http_compression:
                request.fields['Accept-Encoding'] = 'gzip, deflate'

            if session.args.no_cache:
                request.fields['Cache-Control'] = 'no-cache, must-revalidate'
                request.fields['Pragma'] = 'no-cache'

            return request

        return request_factory
1064631
async def _request(self, *, http_verb, api_url, req_args):
        
        if self.session and not self.session.closed:
            async with self.session.request(http_verb, api_url, **req_args) as res:
                self._logger.debug("Ran the request with existing session.")
                return {
                    "data": await res.json(),
                    "headers": res.headers,
                    "status_code": res.status,
                }
        async with aiohttp.ClientSession(
            loop=self._event_loop, timeout=aiohttp.ClientTimeout(total=self.timeout)
        ) as session:
            async with session.request(http_verb, api_url, **req_args) as res:
                self._logger.debug("Ran the request with a new session.")
                return {
                    "data": await res.json(),
                    "headers": res.headers,
                    "status_code": res.status,
                }
472859
async def create_session(self, **kwargs):
        
        self.opts.update(kwargs)
        self._session = aiohttp.ClientSession(**self.opts, loop=self._loop)
        if self.redis_opts:
            if aioredis:
                self._redis = await aioredis.create_redis(**self.redis_opts,
                                                          loop=self._loop)
            else:
                warnings.warn(no_redis_warning)
710204
def create_session(self, name=None):
        
        self.session = Session.create(self, name=name)
        return self.session
114607
function createSession(config, cb) {
  cb = utils.callOnce(cb)

  DEBUG("create", utils.JS(config))

  var channel = channels.createChannel(config.url)
  var session = new Session(channel, config, cb)
}
210610
def request(self, method, params, session):
        
        session = session or self.client.session
        request = self.create_req(method, params)
        date_time_sent = datetime.datetime.utcnow()
        try:
            response = session.post(
                self.url,
                data=request,
                headers=self.client.request_headers,
                timeout=(self.connect_timeout, self.read_timeout)
            )
        except ConnectionError:
            raise APIError(None, method, params, 'ConnectionError')
        except Exception as e:
            raise APIError(None, method, params, e)
        elapsed_time = (datetime.datetime.utcnow()-date_time_sent).total_seconds()

        check_status_code(response)
        try:
            response_data = response.json()
        except ValueError:
            raise InvalidResponse(response.text)

        if self._error_handler:
            self._error_handler(response_data, method, params)
        return response_data, elapsed_time
205401
async def open_session(self, request: BaseRequestWebsocket) -> Session:
        """"""
        return await ensure_coroutine(self.session_interface.open_session)(self, request)
16022
def create(request):
    
    name = request.POST.get("name")
    if name:
        room, created = ChatRoom.objects.get_or_create(name=name)
        return redirect(room)
    return redirect(rooms)
981352
def request(self, method, url, **kwargs):
        """"""
        if not url.startswith('https'):
            url = '{}{}'.format(self.args.tc_api_path, url)
        return super(TcExSession, self).request(method, url, **kwargs)
1150616
def make_request(self, session, url, **kwargs):
        
        log.debug('Making request: GET %s %s' % (url, kwargs))
        return session.get(url, **kwargs)
230549
def request(self, *args, **kwargs):
        
        return self.session.request(*args, **self.get_kwargs(**kwargs))
1063733
def new_session(self):
        """"""
        body = yield from self._fetch_json(URL_LOGIN, self._new_session_data)
        self.sma_sid = jmespath.search('result.sid', body)
        if self.sma_sid:
            return True

        msg = 'Could not start session, %s, got {}'.format(body)

        if body.get('err'):
            if body.get('err') == 503:
                _LOGGER.error("Max amount of sessions reached")
            else:
                _LOGGER.error(msg, body.get('err'))
        else:
            _LOGGER.error(msg, "Session ID expected [result.sid]")
        return False
283406
def create_request(self):
        
        fis_service = FisService(instance_id=self.instance_id)
        self.download_list = fis_service.get_request(self)
1255314
def _request(self, *args, **kwargs):
        # type (Any) -> Response
        """"""
        self._amend_request_kwargs(kwargs)
        _response = self._requests_session.request(*args, **kwargs)
        try:
            _response.raise_for_status()
        except HTTPError as e:
            if e.response is not None:
                raise_from(ConjureHTTPError(e), e)
            raise e
        return _response
1112068
def send_request(self, *args, **kwargs):
        
        try:
            return self.session.request(*args, **kwargs)
        except ConnectionError:
            self.session.close()
            return self.session.request(*args, **kwargs)