(self, response, request)
return cookies
Return sequence of Cookie objects extracted from response object.
Return sequence of Cookie objects extracted from response object.
Return sequence of Cookie objects extracted from response object .
def make_cookies(self, response, request):
        """Return sequence of Cookie objects extracted from response object."""
        # get cookie-attributes for RFC 2965 and Netscape protocols
        headers = response.info()
        rfc2965_hdrs = headers.get_all("Set-Cookie2", [])
        ns_hdrs = headers.get_all("Set-Cookie", [])
        self._policy._now = self._now = int(time.time())

        rfc2965 = self._policy.rfc2965
        netscape = self._policy.netscape

        if ((not rfc2965_hdrs and not ns_hdrs) or
            (not ns_hdrs and not rfc2965) or
            (not rfc2965_hdrs and not netscape) or
            (not netscape and not rfc2965)):
            return []  # no relevant cookie headers: quick exit

        try:
            cookies = self._cookies_from_attrs_set(
                split_header_words(rfc2965_hdrs), request)
        except Exception:
            _warn_unhandled_exception()
            cookies = []

        if ns_hdrs and netscape:
            try:
                # RFC 2109 and Netscape cookies
                ns_cookies = self._cookies_from_attrs_set(
                    parse_ns_headers(ns_hdrs), request)
            except Exception:
                _warn_unhandled_exception()
                ns_cookies = []
            self._process_rfc2109_cookies(ns_cookies)

            # Look for Netscape cookies (from Set-Cookie headers) that match
            # corresponding RFC 2965 cookies (from Set-Cookie2 headers).
            # For each match, keep the RFC 2965 cookie and ignore the Netscape
            # cookie (RFC 2965 section 9.1).  Actually, RFC 2109 cookies are
            # bundled in with the Netscape cookies for this purpose, which is
            # reasonable behaviour.
            if rfc2965:
                lookup = {}
                for cookie in cookies:
                    lookup[(cookie.domain, cookie.path, cookie.name)] = None

                def no_matching_rfc2965(ns_cookie, lookup=lookup):
                    key = ns_cookie.domain, ns_cookie.path, ns_cookie.name
                    return key not in lookup
                ns_cookies = filter(no_matching_rfc2965, ns_cookies)

            if ns_cookies:
                cookies.extend(ns_cookies)

        return cookies
def make_cookies ( self , response , request ) : # get cookie-attributes for RFC 2965 and Netscape protocols headers = response . info ( ) rfc2965_hdrs = headers . get_all ( "Set-Cookie2" , [ ] ) ns_hdrs = headers . get_all ( "Set-Cookie" , [ ] ) self . _policy . _now = self . _now = int ( time . time ( ) ) rfc2965 = self . _policy . rfc2965 netscape = self . _policy . netscape if ( ( not rfc2965_hdrs and not ns_hdrs ) or ( not ns_hdrs and not rfc2965 ) or ( not rfc2965_hdrs and not netscape ) or ( not netscape and not rfc2965 ) ) : return [ ] # no relevant cookie headers: quick exit try : cookies = self . _cookies_from_attrs_set ( split_header_words ( rfc2965_hdrs ) , request ) except Exception : _warn_unhandled_exception ( ) cookies = [ ] if ns_hdrs and netscape : try : # RFC 2109 and Netscape cookies ns_cookies = self . _cookies_from_attrs_set ( parse_ns_headers ( ns_hdrs ) , request ) except Exception : _warn_unhandled_exception ( ) ns_cookies = [ ] self . _process_rfc2109_cookies ( ns_cookies ) # Look for Netscape cookies (from Set-Cookie headers) that match # corresponding RFC 2965 cookies (from Set-Cookie2 headers). # For each match, keep the RFC 2965 cookie and ignore the Netscape # cookie (RFC 2965 section 9.1).  Actually, RFC 2109 cookies are # bundled in with the Netscape cookies for this purpose, which is # reasonable behaviour. if rfc2965 : lookup = { } for cookie in cookies : lookup [ ( cookie . domain , cookie . path , cookie . name ) ] = None def no_matching_rfc2965 ( ns_cookie , lookup = lookup ) : key = ns_cookie . domain , ns_cookie . path , ns_cookie . name return key not in lookup ns_cookies = filter ( no_matching_rfc2965 , ns_cookies ) if ns_cookies : cookies . extend ( ns_cookies ) return cookies