本文整理匯總了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'
#.........這裏部分代碼省略.........