本文整理汇总了Python中pulsar.utils.httpurl.SimpleCookie.load方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleCookie.load方法的具体用法?Python SimpleCookie.load怎么用?Python SimpleCookie.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulsar.utils.httpurl.SimpleCookie
的用法示例。
在下文中一共展示了SimpleCookie.load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cookies
# 需要导入模块: from pulsar.utils.httpurl import SimpleCookie [as 别名]
# 或者: from pulsar.utils.httpurl.SimpleCookie import load [as 别名]
def cookies(self):
"""Container of request cookies
"""
cookies = SimpleCookie()
cookie = self.environ.get('HTTP_COOKIE')
if cookie:
cookies.load(cookie)
return cookies
示例2: test_parse_cookie
# 需要导入模块: from pulsar.utils.httpurl import SimpleCookie [as 别名]
# 或者: from pulsar.utils.httpurl.SimpleCookie import load [as 别名]
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': ''})
示例3: WsgiResponse
# 需要导入模块: from pulsar.utils.httpurl import SimpleCookie [as 别名]
# 或者: from pulsar.utils.httpurl.SimpleCookie import load [as 别名]
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:`.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.
'''
_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
if environ:
cookie = environ.get('HTTP_COOKIE')
if cookie:
self.cookies.load(cookie)
@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')
@property
def environ_cache(self):
if self.environ:
return self.environ.get('pulsar.cache')
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):
if not self.encoding: # use utf-8 if not set
self.encoding = 'utf-8'
content = content.encode(self.encoding)
else: # pragma nocover
if isinstance(content, unicode):
if not self.encoding: # use utf-8 if not set
self.encoding = 'utf-8'
#.........这里部分代码省略.........