def filter_cookies(self, request_url: URL=URL()) -> 'BaseCookie[str]':
        """Returns this jar's cookies filtered by their attributes."""
        self._do_expiration()
        request_url = URL(request_url)
        filtered = SimpleCookie()
        hostname = request_url.raw_host or ""
        is_not_secure = request_url.scheme not in ("https", "wss")

        for cookie in self:
            name = cookie.key
            domain = cookie["domain"]

            # Send shared cookies
            if not domain:
                filtered[name] = cookie.value
                continue

            if not self._unsafe and is_ip_address(hostname):
                continue

            if (domain, name) in self._host_only_cookies:
                if domain != hostname:
                    continue
            elif not self._is_domain_match(domain, hostname):
                continue

            if not self._is_path_match(request_url.path, cookie["path"]):
                continue

            if is_not_secure and cookie["secure"]:
                continue

            # It's critical we use the Morsel so the coded_value
            # (based on cookie version) is preserved
            mrsl_val = cast('Morsel[str]', cookie.get(cookie.key, Morsel()))
            mrsl_val.set(cookie.key, cookie.value, cookie.coded_value)
            filtered[name] = mrsl_val

        return filtered
def filter_cookies ( self , request_url : URL = URL ( ) ) -> 'BaseCookie[str]' : self . _do_expiration ( ) request_url = URL ( request_url ) filtered = SimpleCookie ( ) hostname = request_url . raw_host or "" is_not_secure = request_url . scheme not in ( "https" , "wss" ) for cookie in self : name = cookie . key domain = cookie [ "domain" ] if not domain : filtered [ name ] = cookie . value continue if not self . _unsafe and is_ip_address ( hostname ) : continue if ( domain , name ) in self . _host_only_cookies : if domain != hostname : continue elif not self . _is_domain_match ( domain , hostname ) : continue if not self . _is_path_match ( request_url . path , cookie [ "path" ] ) : continue if is_not_secure and cookie [ "secure" ] : continue mrsl_val = cast ( 'Morsel[str]' , cookie . get ( cookie . key , Morsel ( ) ) ) mrsl_val . set ( cookie . key , cookie . value , cookie . coded_value ) filtered [ name ] = mrsl_val return filtered
Returns this jar's cookies filtered by their attributes.