commit
865506546f
|
@ -1,4 +1,3 @@
|
||||||
from datetime import datetime
|
|
||||||
import re
|
import re
|
||||||
import string
|
import string
|
||||||
|
|
||||||
|
@ -104,13 +103,19 @@ class Cookie(dict):
|
||||||
def encode(self, encoding):
|
def encode(self, encoding):
|
||||||
output = ['%s=%s' % (self.key, _quote(self.value))]
|
output = ['%s=%s' % (self.key, _quote(self.value))]
|
||||||
for key, value in self.items():
|
for key, value in self.items():
|
||||||
if key == 'max-age' and isinstance(value, int):
|
if key == 'max-age':
|
||||||
output.append('%s=%d' % (self._keys[key], value))
|
try:
|
||||||
elif key == 'expires' and isinstance(value, datetime):
|
output.append('%s=%d' % (self._keys[key], value))
|
||||||
output.append('%s=%s' % (
|
except TypeError:
|
||||||
self._keys[key],
|
output.append('%s=%s' % (self._keys[key], value))
|
||||||
value.strftime("%a, %d-%b-%Y %T GMT")
|
elif key == 'expires':
|
||||||
))
|
try:
|
||||||
|
output.append('%s=%s' % (
|
||||||
|
self._keys[key],
|
||||||
|
value.strftime("%a, %d-%b-%Y %T GMT")
|
||||||
|
))
|
||||||
|
except AttributeError:
|
||||||
|
output.append('%s=%s' % (self._keys[key], value))
|
||||||
elif key in self._flags:
|
elif key in self._flags:
|
||||||
if self[key]:
|
if self[key]:
|
||||||
output.append(self._keys[key])
|
output.append(self._keys[key])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user