• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python httpurl.SimpleCookie类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pulsar.utils.httpurl.SimpleCookie的典型用法代码示例。如果您正苦于以下问题:Python SimpleCookie类的具体用法?Python SimpleCookie怎么用?Python SimpleCookie使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SimpleCookie类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: cookies

 def cookies(self):
     """Container of request cookies
     """
     cookies = SimpleCookie()
     cookie = self.environ.get('HTTP_COOKIE')
     if cookie:
         cookies.load(cookie)
     return cookies
开发者ID:yl849646685,项目名称:pulsar,代码行数:8,代码来源:wrappers.py


示例2: test_cookies

 def test_cookies(self):
     h = Headers()
     cookies = SimpleCookie({'bla': 'foo', 'pippo': 'pluto'})
     self.assertEqual(len(cookies), 2)
     for c in cookies.values():
         v = c.OutputString()
         h.add_header('Set-Cookie', v)
     h = str(h)
     self.assertTrue(
         h in ('Set-Cookie: bla=foo\r\nSet-Cookie: pippo=pluto\r\n\r\n',
               'Set-Cookie: pippo=pluto\r\nSet-Cookie: bla=foo\r\n\r\n'))
开发者ID:Danzeer,项目名称:pulsar,代码行数:11,代码来源:headers.py


示例3: test_parse_cookie

 def test_parse_cookie(self):
     self.assertEqual(parse_cookie('invalid key=true'),
                      {'key':'true'})
     self.assertEqual(parse_cookie('invalid;key=true'),
                      {'key':'true'})
     self.assertEqual(parse_cookie(''), {})
     self.assertEqual(parse_cookie(None), {})
     c = SimpleCookie()
     c.load('key=true')
     self.assertEqual(parse_cookie(c), {'key':'true'})
     self.assertEqual(parse_cookie('key='), {'key': ''})
开发者ID:BazookaShao,项目名称:pulsar,代码行数:11,代码来源:tools.py


示例4: __init__

 def __init__(self, status=None, content=None, response_headers=None,
              content_type=None, encoding=None, environ=None):
     self.environ = environ
     self.status_code = status or self.DEFAULT_STATUS_CODE
     self.encoding = encoding
     self.cookies = SimpleCookie()
     self.headers = Headers(response_headers, kind='server')
     self.content = content
     if content_type is not None:
         self.content_type = content_type
开发者ID:etataurov,项目名称:pulsar,代码行数:10,代码来源:wrappers.py


示例5: __init__

 def __init__(self, status=None, content=None, response_headers=None,
              content_type=None, encoding=None, environ=None,
              can_store_cookies=True):
     self.environ = environ
     self.status_code = status or self.DEFAULT_STATUS_CODE
     self.encoding = encoding
     self.cookies = SimpleCookie()
     self.headers = Headers(response_headers, kind='server')
     self.content = content
     self._can_store_cookies = can_store_cookies
     if content_type is not None:
         self.content_type = content_type
     if environ:
         cookie = environ.get('HTTP_COOKIE')
         if cookie:
             self.cookies.load(cookie)
开发者ID:JinsongBian,项目名称:pulsar,代码行数:16,代码来源:wrappers.py


示例6: __init__

 def __init__(
     self,
     status=None,
     content=None,
     response_headers=None,
     content_type=None,
     encoding=None,
     environ=None,
     start_response=None,
 ):
     super(WsgiResponse, self).__init__(environ, start_response)
     self.status_code = status or self.DEFAULT_STATUS_CODE
     self.encoding = encoding
     self.cookies = SimpleCookie()
     self.headers = Headers(response_headers, kind="server")
     self.content = content
     if content_type is not None:
         self.content_type = content_type
开发者ID:ilmiacs,项目名称:pulsar,代码行数:18,代码来源:wsgi.py


示例7: WsgiResponse

class WsgiResponse:
    """A WSGI response.

    Instances are callable using the standard WSGI call and, importantly,
    iterable::

        response = WsgiResponse(200)

    A :class:`WsgiResponse` is an iterable over bytes to send back to the
    requesting client.

    .. attribute:: status_code

        Integer indicating the HTTP status, (i.e. 200)

    .. attribute:: response

        String indicating the HTTP status (i.e. 'OK')

    .. attribute:: status

        String indicating the HTTP status code and response (i.e. '200 OK')

    .. attribute:: content_type

        The content type of this response. Can be ``None``.

    .. attribute:: headers

        The :class:`.Headers` container for this response.

    .. attribute:: environ

        The dictionary of WSGI environment if passed to the constructor.

    .. attribute:: cookies

        A python :class:`SimpleCookie` container of cookies included in the
        request as well as cookies set during the response.
    """
    _iterated = False
    _started = False
    DEFAULT_STATUS_CODE = 200

    def __init__(self, status=None, content=None, response_headers=None,
                 content_type=None, encoding=None, environ=None,
                 can_store_cookies=True):
        self.environ = environ
        self.status_code = status or self.DEFAULT_STATUS_CODE
        self.encoding = encoding
        self.cookies = SimpleCookie()
        self.headers = Headers(response_headers, kind='server')
        self.content = content
        self._can_store_cookies = can_store_cookies
        if content_type is not None:
            self.content_type = content_type

    @property
    def started(self):
        return self._started

    @property
    def iterated(self):
        return self._iterated

    @property
    def path(self):
        if self.environ:
            return self.environ.get('PATH_INFO', '')

    @property
    def method(self):
        if self.environ:
            return self.environ.get('REQUEST_METHOD')

    @property
    def connection(self):
        if self.environ:
            return self.environ.get('pulsar.connection')

    @property
    def content(self):
        return self._content

    @content.setter
    def content(self, content):
        if not self._iterated:
            if content is None:
                content = ()
            else:
                if isinstance(content, str):
                    if not self.encoding:   # use utf-8 if not set
                        self.encoding = 'utf-8'
                    content = content.encode(self.encoding)

            if isinstance(content, bytes):
                content = (content,)
            self._content = content
        else:
            raise RuntimeError('Cannot set content. Already iterated')
#.........这里部分代码省略.........
开发者ID:yl849646685,项目名称:pulsar,代码行数:101,代码来源:wrappers.py


示例8: WsgiResponse

class WsgiResponse(WsgiResponseGenerator):
    """A WSGI response wrapper initialized by a WSGI request middleware.
Instances are callable using the standard WSGI call::

    response = WsgiResponse(200)
    response(environ, start_response)

A :class:`WsgiResponse` is an iterable over bytes to send back to the requesting
client.

.. attribute:: status_code

    Integer indicating the HTTP status, (i.e. 200)

.. attribute:: response

    String indicating the HTTP status (i.e. 'OK')

.. attribute:: status

    String indicating the HTTP status code and response (i.e. '200 OK')

.. attribute:: environ

    The dictionary of WSGI environment if passed to the constructor.

"""

    _started = False
    DEFAULT_STATUS_CODE = 200

    def __init__(
        self,
        status=None,
        content=None,
        response_headers=None,
        content_type=None,
        encoding=None,
        environ=None,
        start_response=None,
    ):
        super(WsgiResponse, self).__init__(environ, start_response)
        self.status_code = status or self.DEFAULT_STATUS_CODE
        self.encoding = encoding
        self.cookies = SimpleCookie()
        self.headers = Headers(response_headers, kind="server")
        self.content = content
        if content_type is not None:
            self.content_type = content_type

    @property
    def started(self):
        return self._started

    @property
    def path(self):
        if self.environ:
            return self.environ.get("PATH_INFO", "")

    @property
    def method(self):
        if self.environ:
            return self.environ.get("REQUEST_METHOD")

    @property
    def connection(self):
        if self.environ:
            return self.environ.get("pulsar.connection")

    def _get_content(self):
        return self._content

    def _set_content(self, content):
        if not self._started:
            if content is None:
                content = ()
            elif ispy3k:  # what a fucking pain
                if isinstance(content, str):
                    content = bytes(content, "latin-1")
            else:  # pragma    nocover
                if isinstance(content, unicode):
                    content = bytes(content, "latin-1")
            if isinstance(content, bytes):
                content = (content,)
            self._content = content
        else:
            raise RuntimeError("Cannot set content. Already iterated")

    content = property(_get_content, _set_content)

    def _get_content_type(self):
        return self.headers.get("content-type")

    def _set_content_type(self, typ):
        if typ:
            self.headers["content-type"] = typ
        else:
            self.headers.pop("content-type", None)

    content_type = property(_get_content_type, _set_content_type)
#.........这里部分代码省略.........
开发者ID:ilmiacs,项目名称:pulsar,代码行数:101,代码来源:wsgi.py


示例9: WsgiResponse

class WsgiResponse(object):
    '''A WSGI response.

    Instances are callable using the standard WSGI call and, importantly,
    iterable::

        response = WsgiResponse(200)

    A :class:`WsgiResponse` is an iterable over bytes to send back to the
    requesting client.

    .. attribute:: status_code

        Integer indicating the HTTP status, (i.e. 200)

    .. attribute:: response

        String indicating the HTTP status (i.e. 'OK')

    .. attribute:: status

        String indicating the HTTP status code and response (i.e. '200 OK')

    .. attribute:: content_type

        The content type of this response. Can be ``None``.

    .. attribute:: headers

        The :class:`pulsar.utils.httpurl.Headers` container for this response.

    .. attribute:: environ

        The dictionary of WSGI environment if passed to the constructor.

    '''
    _started = False
    DEFAULT_STATUS_CODE = 200

    def __init__(self, status=None, content=None, response_headers=None,
                 content_type=None, encoding=None, environ=None):
        self.environ = environ
        self.status_code = status or self.DEFAULT_STATUS_CODE
        self.encoding = encoding
        self.cookies = SimpleCookie()
        self.headers = Headers(response_headers, kind='server')
        self.content = content
        if content_type is not None:
            self.content_type = content_type

    @property
    def started(self):
        return self._started

    @property
    def path(self):
        if self.environ:
            return self.environ.get('PATH_INFO', '')

    @property
    def method(self):
        if self.environ:
            return self.environ.get('REQUEST_METHOD')

    @property
    def connection(self):
        if self.environ:
            return self.environ.get('pulsar.connection')

    def _get_content(self):
        return self._content

    def _set_content(self, content):
        if not self._started:
            if content is None:
                content = ()
            elif ispy3k:
                if isinstance(content, str):
                    content = content.encode(self.encoding or 'utf-8')
            else:   # pragma    nocover
                if isinstance(content, unicode):
                    content = content.encode(self.encoding or 'utf-8')
            if isinstance(content, bytes):
                content = (content,)
            self._content = content
        else:
            raise RuntimeError('Cannot set content. Already iterated')
    content = property(_get_content, _set_content)

    def _get_content_type(self):
        return self.headers.get('content-type')

    def _set_content_type(self, typ):
        if typ:
            self.headers['content-type'] = typ
        else:
            self.headers.pop('content-type', None)
    content_type = property(_get_content_type, _set_content_type)

    def length(self):
#.........这里部分代码省略.........
开发者ID:elimisteve,项目名称:pulsar,代码行数:101,代码来源:wrappers.py



注:本文中的pulsar.utils.httpurl.SimpleCookie类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python internet.format_address函数代码示例发布时间:2022-05-25
下一篇:
Python httpurl.Headers类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap