當前位置: 首頁>>代碼示例>>Python>>正文


Python BaseCookie.values方法代碼示例

本文整理匯總了Python中Cookie.BaseCookie.values方法的典型用法代碼示例。如果您正苦於以下問題:Python BaseCookie.values方法的具體用法?Python BaseCookie.values怎麽用?Python BaseCookie.values使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cookie.BaseCookie的用法示例。


在下文中一共展示了BaseCookie.values方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: do_request

# 需要導入模塊: from Cookie import BaseCookie [as 別名]
# 或者: from Cookie.BaseCookie import values [as 別名]
    def do_request(self, req, status, expect_errors):
        """
        Override webtest.TestApp's method so that we do real HTTP requests
        instead of WSGI calls.
        """
        headers = {}
        if self.cookies:
            c = BaseCookie()
            for name, value in self.cookies.items():
                c[name] = value
            hc = '; '.join(['='.join([m.key, m.value]) for m in c.values()])
            req.headers['Cookie'] = hc

        res = self._do_httplib_request(req)
        # Set these attributes for consistency with webtest.
        res.request = req
        res.test_app = self

        if not expect_errors:
            self._check_status(res.status_int, res)
            self._check_errors(res)
        res.cookies_set = {}

        for header in res.headers.getall('set-cookie'):
            try:
                c = BaseCookie(header)
            except CookieError, e:
                raise CookieError(
                    "Could not parse cookie header %r: %s" % (header, e))
            for key, morsel in c.items():
                self.cookies[key] = morsel.value
                res.cookies_set[key] = morsel.value
開發者ID:pasieronen,項目名稱:robotframework-httplibrary,代碼行數:34,代碼來源:livetest.py

示例2: do_request

# 需要導入模塊: from Cookie import BaseCookie [as 別名]
# 或者: from Cookie.BaseCookie import values [as 別名]
    def do_request(self, req, status, expect_errors):
        """
        Override webtest.TestApp's method so that we do real HTTP requests
        instead of WSGI calls.
        """
        headers = {}
        if self.cookies:
            c = BaseCookie()
            for name, value in self.cookies.items():
                c[name] = value
            hc = '; '.join(['='.join([m.key, m.value]) for m in c.values()])
            req.headers['Cookie'] = hc

        res = self._do_httplib_request(req)
        # Set these attributes for consistency with webtest.
        res.request = req
        res.test_app = self

        if not expect_errors:
            self._check_status(res.status_int, res)
            self._check_errors(res)
        res.cookies_set = {}

        # merge cookies back in
        self.cookiejar.extract_cookies(ResponseCookieAdapter(res),
                                       RequestCookieAdapter(req))

        return res
開發者ID:AlahmadiQ8,項目名稱:robotframework-httplibrary,代碼行數:30,代碼來源:livetest.py


注:本文中的Cookie.BaseCookie.values方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。