Fetch a response from the remote CAS `proxyValidate` endpoint.
191025
def perform_proxy_validate(self, proxied_service_ticket, headers=None):
        '''
        
        '''
        url = self._get_proxy_validate_url(ticket=proxied_service_ticket)
        logging.debug('[CAS] ProxyValidate URL: {}'.format(url))
        return self._perform_cas_call(
            url,
            ticket=proxied_service_ticket,
            headers=headers,
            )
923533
def get_fetch_response(self, raw):
        """"""
        p = Payload(raw)
        p._body = p.body
        return p
554045
def response(self, msgtype, msgid, error, result):
        """"""
        self._proxy.response(msgid, error, result)
43601
def response_hook(self, r, **kwargs):
        """"""
        if r.status_code == 401:
            # Handle server auth.
            www_authenticate = r.headers.get('www-authenticate', '').lower()
            auth_type = _auth_type_from_header(www_authenticate)

            if auth_type is not None:
                return self.retry_using_http_NTLM_auth(
                    'www-authenticate',
                    'Authorization',
                    r,
                    auth_type,
                    kwargs
                )
        elif r.status_code == 407:
            # If we didn't have server auth, do proxy auth.
            proxy_authenticate = r.headers.get(
                'proxy-authenticate', ''
            ).lower()
            auth_type = _auth_type_from_header(proxy_authenticate)
            if auth_type is not None:
                return self.retry_using_http_NTLM_auth(
                    'proxy-authenticate',
                    'Proxy-authorization',
                    r,
                    auth_type,
                    kwargs
                )

        return r
1114573
def handleStatus(self, version, code, message):
        ""
        proxy.ProxyClient.handleStatus(self, version, code, message)
        # client.Response is currently just a container for needed data
        self._response = client.Response(version, code, message, {}, None)
1183446
function icyOnResponse (res) {
  debug('request "response" event');

  var s = res;
  var metaint = res.headers['icy-metaint'];
  if (metaint) {
    debug('got metaint: %d', metaint);
    s = new Reader(metaint);
    res.pipe(s);

    s.res = res;

    Object.keys(res).forEach(function (k) {
      if ('_' === k[0]) return;
      debug('proxying %j', k);
      proxy(s, k);
    });
  }
  if (res.connection._wasIcy) {
    s.httpVersion = 'ICY';
  }
  this.emit('icyResponse', s);
}
1174248
def proxy_callback_allowed(service, pgturl):
    """"""
    if hasattr(settings, 'MAMA_CAS_SERVICES'):
        return _is_allowed('proxy_callback_allowed', service, pgturl)
    return _is_valid_service_url(service)
1054756
def authenticated_get(username, password, url, verify=True):
    
    try:
        response = requests.get(url, auth=(username, password), verify=verify)
        if response.status_code == 401:
            raise BadCredentialsException(
                "Unable to authenticate user %s to %s with password provided!"
                % (username, url))
    except requests.exceptions.SSLError:
        raise CertificateException("Unable to verify certificate at %s!" % url)
    return response.content
1262717
def get_http_response(self):
        """"""
        return _get_response(
            code=self.code,
            body=str(self),
            headers={
                'Content-Type': 'text/plain'
            }
        )
1224341
async def _get_response(self, msg):
        """"""
        try:
            protocol = await self._get_protocol()
            pr = protocol.request(msg)
            r = await pr.response
            return pr, r
        except ConstructionRenderableError as e:
            raise ClientError("There was an error with the request.", e)
        except RequestTimedOut as e:
            await self._reset_protocol(e)
            raise RequestTimeout('Request timed out.', e)
        except (OSError, socket.gaierror, Error) as e:
            # aiocoap sometimes raises an OSError/socket.gaierror too.
            # aiocoap issue #124
            await self._reset_protocol(e)
            raise ServerError("There was an error with the request.", e)
        except asyncio.CancelledError as e:
            await self._reset_protocol(e)
            raise e
151914
def proc_response(self, resp):
        """"""

        # Try to interpret any JSON
        try:
            resp.obj = json.loads(resp.body)
            self._debug("  Received entity: %r", resp.obj)
        except ValueError:
            resp.obj = None
            self._debug("  No received entity; body %r", resp.body)

        # Now, call superclass method for error handling
        super(JSONRequest, self).proc_response(resp)
544475
def _get_response(self, endpoint, query, is_post=False):
        """"""
        timeout_secs = self._settings.get('timeout', 10)
        headers = self._settings.get('request_headers', {})
        try:
            if is_post:
                response = requests.post(
                    endpoint, data=query, headers=headers, timeout=timeout_secs)
            else:
                response = requests.get(
                    endpoint, params=query, headers=headers, timeout=timeout_secs)
        except requests.exceptions.Timeout as e:
            raise Exception(
                'API request timed out after %s seconds.' % timeout_secs)
        except Exception as e:
            raise e

        if response.status_code != 200:
            raise Exception('Received status code %s from %s. Content is:\n%s'
                            % (response.status_code,
                               self.get_service_name(),
                               response.text))
        return response
998268
async def fetch_api_description(
        url: typing.Union[str, ParseResult, SplitResult],
        insecure: bool = False):
    """"""
    url_describe = urljoin(_ensure_url_string(url), "describe/")
    connector = aiohttp.TCPConnector(verify_ssl=(not insecure))
    session = aiohttp.ClientSession(connector=connector)
    async with session, session.get(url_describe) as response:
        if response.status != HTTPStatus.OK:
            raise RemoteError(
                "{0} -> {1.status} {1.reason}".format(
                    url, response))
        elif response.content_type != "application/json":
            raise RemoteError(
                "Expected application/json, got: %s"
                % response.content_type)
        else:
            return await response.json()
101830
def _fetch(self):
        
        if self.closed():
            raise self.Error("Failed to read from closed connection {!r}".format(self.server.address))
        if self.defunct():
            raise self.Error("Failed to read from defunct connection {!r}".format(self.server.address))
        if not self.responses:
            return 0, 0

        self._receive()

        details, summary_signature, summary_metadata = self._unpack()

        if details:
            log_debug("[#%04X]  S: RECORD * %d", self.local_port, len(details))  # TODO
            self.responses[0].on_records(details)

        if summary_signature is None:
            return len(details), 0

        response = self.responses.popleft()
        response.complete = True
        if summary_signature == b"\x70":
            log_debug("[#%04X]  S: SUCCESS %r", self.local_port, summary_metadata)
            response.on_success(summary_metadata or {})
        elif summary_signature == b"\x7E":
            self._last_run_statement = None
            log_debug("[#%04X]  S: IGNORED", self.local_port)
            response.on_ignored(summary_metadata or {})
        elif summary_signature == b"\x7F":
            self._last_run_statement = None
            log_debug("[#%04X]  S: FAILURE %r", self.local_port, summary_metadata)
            response.on_failure(summary_metadata or {})
        else:
            self._last_run_statement = None
            raise ProtocolError("Unexpected response message with signature %02X" % summary_signature)

        return len(details), 1
94142
def denied_response(self, req):
        
        if not hasattr(req, 'credentials_valid'):
            req.credentials_valid = None
        if req.remote_user or req.credentials_valid:
            return HTTPForbidden(request=req)
        else:
            return HTTPUnauthorized(request=req)
864606
def fetch(self, endpoint, data = None):
        
        payload = {
            "lastServerChangeId": "-1",
            "csrf": self.__csrf,
            "apiClient": "WEB"
        }
        if data is not None:
            payload.update(data)

        return self.post(endpoint, payload)
930962
function parseCasResponse(casBody, logger, callback) {
  xml2js(casBody, {
    explicitRoot: false,
    tagNameProcessors: [stripPrefix]
  }, function(err, serviceResponse) {
    /* istanbul ignore if */
    if (err) {
      logger.error('Failed to parse CAS server response when trying to validate ticket.');
      logger.error(err);
      return callback(err, {
        message: 'Failed to parse CAS server response when trying to validate ticket.'
      });
    }

    if (!serviceResponse) {
      logger.error('Invalid CAS server response.');
      return callback(new Error('Invalid CAS server response, serviceResponse empty.'), {
        message: 'Invalid CAS server response, serviceResponse empty.'
      });
    }

    var success = serviceResponse.authenticationSuccess && serviceResponse.authenticationSuccess[0];

    if (!success) {
      logger.error('Receive response from CAS when validating ticket, but the validation is failed.');
      logger.error('Cas response:', serviceResponse);
      return callback(null, {});
    }

    var casResponse = {};
    for (var casProperty in success) {
      casResponse[casProperty] = success[casProperty][0];
    }

    return callback(null, casResponse);
  })
}