Return connection handler instance for the endpoint

        :param session: AIOHTTP client session instance
        :param proxy: Proxy url
        :return:
165352
def conn_handler(self, session: ClientSession, proxy: str = None) -> ConnectionHandler:
        
        if self.server:
            return ConnectionHandler("https", "wss", self.server, self.port, self.path, session, proxy)
        elif self.ipv6:
            return ConnectionHandler("https", "wss", "[{0}]".format(self.ipv6), self.port, self.path, session, proxy)

        return ConnectionHandler("https", "wss", self.ipv4, self.port, self.path, session, proxy)
337839
private static URLConnection getConnection(String url, final ProxyConfig proxy) throws IOException {
        URLConnection conn = null;

        if (proxy != null && proxy.getProxyUser() != null) {
            Authenticator.setDefault(new Authenticator() {
                @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(proxy.getProxyUser(), proxy.getProxyPassword().toCharArray());
                }

            });
        }

        if (proxy != null) {
            Proxy thisProxy = new Proxy(proxy.getProxyType(), new InetSocketAddress(proxy.getProxyHost(), proxy.getProxyPort()));
            conn = new URL(url).openConnection(thisProxy);
        } else {
            conn = new URL(url).openConnection();
        }

        return conn;
    }
479381
def requests_session(self, *args, **kwargs):
        
        import requests
        auth1 = self.generate_auth()
        return requests.Session(*args, auth=auth1, **kwargs)
278537
def make_handlers(base_url, server_processes):
    
    handlers = []
    for sp in server_processes:
        handler = _make_serverproxy_handler(
            sp.name,
            sp.command,
            sp.environment,
            sp.timeout,
            sp.absolute_url,
            sp.port,
        )
        handlers.append((
            ujoin(base_url, sp.name, r'(.*)'), handler, dict(state={}),
        ))
        handlers.append((
            ujoin(base_url, sp.name), AddSlashHandler
        ))
    return handlers
786734
def _build_connection_pool(cls, session: AppSession):
        ''''''
        args = session.args
        connect_timeout = args.connect_timeout
        read_timeout = args.read_timeout

        if args.timeout:
            connect_timeout = read_timeout = args.timeout

        if args.limit_rate:
            bandwidth_limiter = session.factory.new('BandwidthLimiter',
                                                    args.limit_rate)
        else:
            bandwidth_limiter = None

        connection_factory = functools.partial(
            Connection,
            timeout=read_timeout,
            connect_timeout=connect_timeout,
            bind_host=session.args.bind_address,
            bandwidth_limiter=bandwidth_limiter,
        )

        ssl_connection_factory = functools.partial(
            SSLConnection,
            timeout=read_timeout,
            connect_timeout=connect_timeout,
            bind_host=session.args.bind_address,
            ssl_context=session.ssl_context,
        )

        if not session.args.no_proxy:
            if session.args.https_proxy:
                http_proxy = session.args.http_proxy.split(':', 1)
                proxy_ssl = True
            elif session.args.http_proxy:
                http_proxy = session.args.http_proxy.split(':', 1)
                proxy_ssl = False
            else:
                http_proxy = None
                proxy_ssl = None

            if http_proxy:
                http_proxy[1] = int(http_proxy[1])

                if session.args.proxy_user:
                    authentication = (session.args.proxy_user,
                                      session.args.proxy_password)
                else:
                    authentication = None

                session.factory.class_map['ConnectionPool'] = \
                    HTTPProxyConnectionPool

                host_filter = session.factory.new(
                    'ProxyHostFilter',
                    accept_domains=session.args.proxy_domains,
                    reject_domains=session.args.proxy_exclude_domains,
                    accept_hostnames=session.args.proxy_hostnames,
                    reject_hostnames=session.args.proxy_exclude_hostnames
                )

                return session.factory.new(
                    'ConnectionPool',
                    http_proxy,
                    proxy_ssl=proxy_ssl,
                    authentication=authentication,
                    resolver=session.factory['Resolver'],
                    connection_factory=connection_factory,
                    ssl_connection_factory=ssl_connection_factory,
                    host_filter=host_filter,
                )

        return session.factory.new(
            'ConnectionPool',
            resolver=session.factory['Resolver'],
            connection_factory=connection_factory,
            ssl_connection_factory=ssl_connection_factory
        )
637165
def get_session_url(session_id, type='view', **params):
        
        url = 'sessions/{}/{}'.format(session_id, type)
        url = urljoin(API_URL, url)
        return add_to_url(url, **params)
230549
def request(self, *args, **kwargs):
        
        return self.session.request(*args, **self.get_kwargs(**kwargs))
430195
def _get_connection(self):
        
        if self._connection is None:
            uri = self.settings.SERVER_URI
            if callable(uri):
                if func_supports_parameter(uri, "request"):
                    uri = uri(self._request)
                else:
                    warnings.warn(
                        "Update AUTH_LDAP_SERVER_URI callable %s.%s to accept "
                        "a positional `request` argument. Support for callables "
                        "accepting no arguments will be removed in a future "
                        "version." % (uri.__module__, uri.__name__),
                        DeprecationWarning,
                    )
                    uri = uri()

            self._connection = self.backend.ldap.initialize(uri, bytes_mode=False)

            for opt, value in self.settings.CONNECTION_OPTIONS.items():
                self._connection.set_option(opt, value)

            if self.settings.START_TLS:
                logger.debug("Initiating TLS")
                self._connection.start_tls_s()

        return self._connection
243539
def _generate_request_handler_proxy(handler_class, handler_args, name):
    """"""

    @scope.inject
    def request_handler_wrapper(app, handler, **kwargs):
        handler = handler_class(app, handler.request, **handler_args)
        handler._execute([], **kwargs)
    request_handler_wrapper.__name__ = name
    request_handler_wrapper.handler_class = handler_class
    request_handler_wrapper.handler_args = handler_args

    return request_handler_wrapper
1152639
async def get_proxies(self):
        
        log.debug('Try to get proxies from %s' % self.domain)

        async with aiohttp.ClientSession(
            headers=get_headers(), cookies=self._cookies, loop=self._loop
        ) as self._session:
            await self._pipe()

        log.debug(
            '%d proxies received from %s: %s'
            % (len(self.proxies), self.domain, self.proxies)
        )
        return self.proxies
626431
def do_open(self, http_class, req, **http_conn_args):
        
        host = req.host
        if not host:
            raise URLError('no host given')

        # will parse host:port
        h = http_class(host, timeout=req.timeout, **http_conn_args)

        headers = dict(req.unredirected_hdrs)
        headers.update(dict((k, v) for k, v in req.headers.items()
                            if k not in headers))

        # TODO(jhylton): Should this be redesigned to handle
        # persistent connections?

        # We want to make an HTTP/1.1 request, but the addinfourl
        # class isn't prepared to deal with a persistent connection.
        # It will try to read all remaining data from the socket,
        # which will block while the server waits for the next request.
        # So make sure the connection gets closed after the (only)
        # request.
        headers["Connection"] = "close"
        headers = dict((name.title(), val) for name, val in headers.items())

        if req._tunnel_host:
            tunnel_headers = {}
            proxy_auth_hdr = "Proxy-Authorization"
            if proxy_auth_hdr in headers:
                tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr]
                # Proxy-Authorization should not be sent to origin
                # server.
                del headers[proxy_auth_hdr]
            h.set_tunnel(req._tunnel_host, headers=tunnel_headers)

        try:
            h.request(req.get_method(), req.selector, req.data, headers)
        except socket.error as err: # timeout error
            h.close()
            raise URLError(err)
        else:
            r = h.getresponse()
            # If the server does not send us a 'Connection: close' header,
            # HTTPConnection assumes the socket should be left open. Manually
            # mark the socket to be closed when this response object goes away.
            if h.sock:
                h.sock.close()
                h.sock = None


        r.url = req.get_full_url()
        # This line replaces the .msg attribute of the HTTPResponse
        # with .headers, because urllib clients expect the response to
        # have the reason in .msg.  It would be good to mark this
        # attribute is deprecated and get then to use info() or
        # .headers.
        r.msg = r.reason
        return r
1319846
def _get_request(self, url, headers, params=None):
        
        return self._session.get(url, headers=headers, params=params)
1373164
def request(self, method, url, **kwargs):
        
        resp = super(ClientSession, self).request(
            method, url, timeout=self._timeout, **kwargs)

        return resp
888890
def request(self, method, url, **kwargs):
        
        if 'timeout' not in kwargs:
            if self.timeout is not None:
                kwargs['timeout'] = self.timeout
            else:
                kwargs['timeout'] = (DEFAULT_CONNECT_TIMEOUT,
                                     DEFAULT_READ_TIMEOUT)
        return super(Session, self).request(method=method, url=url, **kwargs)
739775
static ConnectionRequest wrap(ConnectionRequest orig) {
        if (orig instanceof Wrapped)
            throw new IllegalArgumentException();
        return (ConnectionRequest) Proxy.newProxyInstance(
                // https://github.com/aws/aws-sdk-java/pull/48#issuecomment-29454423
                ClientConnectionRequestFactory.class.getClassLoader(),
                interfaces,
                new Handler(orig));
    }
364743
def _get_session(self, session):
        

        if not session:
            logger.debug('(SESSION_CREATE) User: %s' % self._user)
            s = requests.Session()
            s.auth = HTTPBasicAuth(self._user, self._password)
        else:
            logger.debug('(SESSION_CREATE) Object: %s' % session)
            s = session

        s.headers.update(
            {
                'content-type': 'application/json',
                'accept': 'application/json',
                'User-Agent': 'pysnow/%s' % pysnow.__version__
            }
        )

        return s
653874
def proxy_callback(request):
    

    pgtIou = request.GET.get('pgtIou')
    tgt = request.GET.get('pgtId')

    if not (pgtIou and tgt):
        logger.info('No pgtIou or tgt found in request.GET')
        return HttpResponse('No pgtIOO', content_type="text/plain")

    try:
        PgtIOU.objects.create(tgt=tgt, pgtIou=pgtIou, created=datetime.datetime.now())
        request.session['pgt-TICKET'] = pgtIou
        return HttpResponse('PGT ticket is: {ticket}'.format(ticket=pgtIou), content_type="text/plain")
    except Exception as e:
        logger.warning('PGT storage failed. {message}'.format(
            message=e
        ))
        return HttpResponse('PGT storage failed for {request}'.format(request=str(request.GET)),
                            content_type="text/plain")