亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? cookie.py

?? Mod_python is an Apache module that embeds the Python interpreter within the server. With mod_python
?? PY
字號:
 # vim: set sw=4 expandtab : # # Copyright 2004 Apache Software Foundation  #  # Licensed under the Apache License, Version 2.0 (the "License"); you # may not use this file except in compliance with the License.  You # may obtain a copy of the License at # #      http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied.  See the License for the specific language governing # permissions and limitations under the License. # # Originally developed by Gregory Trubetskoy. # # $Id: Cookie.py 472053 2006-11-07 10:11:01Z grahamd $"""This module contains classes to support HTTP State ManagementMechanism, also known as Cookies. The classes provide simpleways for creating, parsing and digitally signing cookies, aswell as the ability to store simple Python objects in Cookies(using marshalling).The behaviour of the classes is designed to be most usefulwithin mod_python applications.The current state of HTTP State Management standardization israther unclear. It appears that the de-facto standard is theoriginal Netscape specification, even though already two RFC'shave been put out (RFC2109 (1997) and RFC2965 (2000)). TheRFC's add a couple of useful features (e.g. using Max-Age insteadof Expires, but my limited tests show that Max-Age is ignoredby the two browsers tested (IE and Safari). As a result of this,perhaps trying to be RFC-compliant (by automatically providingMax-Age and Version) could be a waste of cookie space..."""import timeimport reimport hmacimport marshalimport base64# import apacheclass CookieError(Exception):    passclass metaCookie(type):    def __new__(cls, clsname, bases, clsdict):        _valid_attr = (            "version", "path", "domain", "secure",            "comment", "expires", "max_age",            # RFC 2965            "commentURL", "discard", "port",            # Microsoft Extension            "httponly" )        # _valid_attr + property values        # (note __slots__ is a new Python feature, it        # prevents any other attribute from being set)        __slots__ = _valid_attr + ("name", "value", "_value",                                   "_expires", "__data__")        clsdict["_valid_attr"] = _valid_attr        clsdict["__slots__"] = __slots__        def set_expires(self, value):            if type(value) == type(""):                # if it's a string, it should be                # valid format as per Netscape spec                try:                    t = time.strptime(value, "%a, %d-%b-%Y %H:%M:%S GMT")                except ValueError:                    raise ValueError, "Invalid expires time: %s" % value                t = time.mktime(t)            else:                # otherwise assume it's a number                # representing time as from time.time()                t = value                value = time.strftime("%a, %d-%b-%Y %H:%M:%S GMT",                                      time.gmtime(t))            self._expires = "%s" % value        def get_expires(self):            return self._expires        clsdict["expires"] = property(fget=get_expires, fset=set_expires)        return type.__new__(cls, clsname, bases, clsdict)class Cookie(object):    """    This class implements the basic Cookie functionality. Note that    unlike the Python Standard Library Cookie class, this class represents    a single cookie (not a list of Morsels).    """    __metaclass__ = metaCookie    DOWNGRADE = 0    IGNORE = 1    EXCEPTION = 3    def parse(Class, str, **kw):        """        Parse a Cookie or Set-Cookie header value, and return        a dict of Cookies. Note: the string should NOT include the        header name, only the value.        """        dict = _parse_cookie(str, Class, **kw)        return dict    parse = classmethod(parse)    def __init__(self, name, value, **kw):        """        This constructor takes at least a name and value as the        arguments, as well as optionally any of allowed cookie attributes        as defined in the existing cookie standards.         """        self.name, self.value = name, value        for k in kw:            setattr(self, k.lower(), kw[k])        # subclasses can use this for internal stuff        self.__data__ = {}    def __str__(self):        """        Provides the string representation of the Cookie suitable for        sending to the browser. Note that the actual header name will        not be part of the string.        This method makes no attempt to automatically double-quote        strings that contain special characters, even though the RFC's        dictate this. This is because doing so seems to confuse most        browsers out there.        """                result = ["%s=%s" % (self.name, self.value)]        for name in self._valid_attr:            if hasattr(self, name):                if name in ("secure", "discard", "httponly"):                    result.append(name)                else:                    result.append("%s=%s" % (name, getattr(self, name)))        return "; ".join(result)        def __repr__(self):        return '<%s: %s>' % (self.__class__.__name__,                                str(self))    class SignedCookie(Cookie):    """    This is a variation of Cookie that provides automatic    cryptographic signing of cookies and verification. It uses    the HMAC support in the Python standard library. This ensures    that the cookie has not been tamprered with on the client side.    Note that this class does not encrypt cookie data, thus it    is still plainly visible as part of the cookie.    """    def parse(Class, s, secret, mismatch=Cookie.DOWNGRADE, **kw):        dict = _parse_cookie(s, Class, **kw)        del_list = []        for k in dict:            c = dict[k]            try:                c.unsign(secret)            except CookieError:                if mismatch == Cookie.EXCEPTION:                     raise                elif mismatch == Cookie.IGNORE:                     del_list.append(k)                else:                     # downgrade to Cookie                     dict[k] = Cookie.parse(Cookie.__str__(c))[k]        for k in del_list:            del dict[k]        return dict    parse = classmethod(parse)    def __init__(self, name, value, secret=None, **kw):        Cookie.__init__(self, name, value, **kw)        self.__data__["secret"] = secret    def hexdigest(self, str):        if not self.__data__["secret"]:            raise CookieError, "Cannot sign without a secret"        _hmac = hmac.new(self.__data__["secret"], self.name)        _hmac.update(str)        return _hmac.hexdigest()    def __str__(self):                result = ["%s=%s%s" % (self.name, self.hexdigest(self.value),                               self.value)]        for name in self._valid_attr:            if hasattr(self, name):                if name in ("secure", "discard", "httponly"):                    result.append(name)                else:                    result.append("%s=%s" % (name, getattr(self, name)))        return "; ".join(result)    def unsign(self, secret):        sig, val = self.value[:32], self.value[32:]        mac = hmac.new(secret, self.name)        mac.update(val)        if mac.hexdigest() == sig:            self.value = val            self.__data__["secret"] = secret        else:            raise CookieError, "Incorrectly Signed Cookie: %s=%s" % (self.name, self.value)class MarshalCookie(SignedCookie):    """    This is a variation of SignedCookie that can store more than    just strings. It will automatically marshal the cookie value,    therefore any marshallable object can be used as value.    The standard library Cookie module provides the ability to pickle    data, which is a major security problem. It is believed that unmarshalling    (as opposed to unpickling) is safe, yet we still err on the side of caution    which is why this class is a subclass of SignedCooke making sure what    we are about to unmarshal passes the digital signature test.    Here is a link to a sugesstion that marshalling is safer than unpickling    http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=7xn0hcugmy.fsf%40ruckus.brouhaha.com    """    def parse(Class, s, secret, mismatch=Cookie.DOWNGRADE, **kw):        dict = _parse_cookie(s, Class, **kw)        del_list = []        for k in dict:            c = dict[k]            try:                c.unmarshal(secret)            except CookieError:                if mismatch == Cookie.EXCEPTION:                     raise                elif mismatch == Cookie.IGNORE:                     del_list.append(k)                else:                     # downgrade to Cookie                     dict[k] = Cookie.parse(Cookie.__str__(c))[k]        for k in del_list:            del dict[k]        return dict    parse = classmethod(parse)    def __str__(self):                m = base64.encodestring(marshal.dumps(self.value))        # on long cookies, the base64 encoding can contain multiple lines        # separated by \n or \r\n        m = ''.join(m.split())        result = ["%s=%s%s" % (self.name, self.hexdigest(m), m)]        for name in self._valid_attr:            if hasattr(self, name):                if name in ("secure", "discard", "httponly"):                    result.append(name)                else:                    result.append("%s=%s" % (name, getattr(self, name)))        return "; ".join(result)    def unmarshal(self, secret):        self.unsign(secret)        try:            data = base64.decodestring(self.value)        except:            raise CookieError, "Cannot base64 Decode Cookie: %s=%s" % (self.name, self.value)        try:            self.value = marshal.loads(data)        except (EOFError, ValueError, TypeError):            raise CookieError, "Cannot Unmarshal Cookie: %s=%s" % (self.name, self.value)# This is a simplified and in some places corrected# (at least I think it is) pattern from standard lib Cookie.py_cookiePattern = re.compile(    r"(?x)"                       # Verbose pattern    r"[,\ ]*"                        # space/comma (RFC2616 4.2) before attr-val is eaten    r"(?P<key>"                   # Start of group 'key'    r"[^;\ =]+"                     # anything but ';', ' ' or '='    r")"                          # End of group 'key'    r"\ *(=\ *)?"                 # a space, then may be "=", more space    r"(?P<val>"                   # Start of group 'val'    r'"(?:[^\\"]|\\.)*"'            # a doublequoted string    r"|"                            # or    r"[^;]*"                        # any word or empty string    r")"                          # End of group 'val'    r"\s*;?"                      # probably ending in a semi-colon    )def _parse_cookie(str, Class, names=None):    # XXX problem is we should allow duplicate    # strings    result = {}    matchIter = _cookiePattern.finditer(str)    for match in matchIter:        key, val = match.group("key"), match.group("val")        # We just ditch the cookies names which start with a dollar sign since        # those are in fact RFC2965 cookies attributes. See bug [#MODPYTHON-3].        if key[0]!='$' and names is None or key in names:            result[key] = Class(key, val)    return resultdef add_cookie(req, cookie, value="", **kw):    """    Sets a cookie in outgoing headers and adds a cache    directive so that caches don't cache the cookie.    """    # is this a cookie?    if not isinstance(cookie, Cookie):        # make a cookie        cookie = Cookie(cookie, value, **kw)            if not req.headers_out.has_key("Set-Cookie"):        req.headers_out.add("Cache-Control", 'no-cache="set-cookie"')    req.headers_out.add("Set-Cookie", str(cookie))def get_cookies(req, Class=Cookie, **kw):    """    A shorthand for retrieveing and parsing cookies given    a Cookie class. The class must be one of the classes from    this module.    """        if not req.headers_in.has_key("cookie"):        return {}    cookies = req.headers_in["cookie"]    if type(cookies) == type([]):        cookies = '; '.join(cookies)    return Class.parse(cookies, **kw)def get_cookie(req, name, Class=Cookie, **kw):    cookies = get_cookies(req, Class, names=[name], **kw)    if cookies.has_key(name):        return cookies[name]

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲天堂免费在线观看视频| av在线免费不卡| 亚洲三级小视频| 国产精品人人做人人爽人人添| 欧美大片国产精品| 精品91自产拍在线观看一区| 精品国产乱码久久久久久图片| 91精品国产综合久久福利软件 | 国产午夜精品一区二区三区四区| 日韩午夜在线观看| 欧美精品一区二区精品网| 久久美女艺术照精彩视频福利播放 | 美国三级日本三级久久99 | 北条麻妃一区二区三区| 北条麻妃一区二区三区| 在线亚洲高清视频| 欧美一区二区三区在线电影 | 国产69精品久久99不卡| 99热在这里有精品免费| 91福利在线导航| 日韩视频免费直播| 国产午夜亚洲精品不卡| 亚洲女性喷水在线观看一区| 无码av中文一区二区三区桃花岛| 男女视频一区二区| 白白色 亚洲乱淫| 欧美精品 日韩| 国产精品美女久久久久av爽李琼| 亚洲精品免费在线观看| 美女一区二区久久| 99精品在线免费| 欧美xxx久久| 伊人色综合久久天天| 久久精品国产精品青草| 99久久久国产精品| 欧美一区二区三区喷汁尤物| 国产精品伦一区| 蜜臀久久久99精品久久久久久| 91在线视频免费观看| 精品国产精品一区二区夜夜嗨| 亚洲免费电影在线| 国产美女在线观看一区| 欧美色视频在线观看| 国产日韩欧美精品一区| 青青草成人在线观看| 97久久久精品综合88久久| 26uuu精品一区二区在线观看| 一区二区三区四区高清精品免费观看 | 精品亚洲成a人| 欧美写真视频网站| 国产精品理论片| 国产一区二区三区在线观看精品 | 亚洲自拍偷拍网站| 成人激情文学综合网| 8x福利精品第一导航| 尤物视频一区二区| 91视频国产资源| 国产精品萝li| 成人永久免费视频| 国产午夜精品一区二区三区嫩草 | 美国十次了思思久久精品导航| 在线视频你懂得一区| 亚洲欧美日韩国产一区二区三区| 精品一区二区在线视频| 91精品国产乱| 美女国产一区二区| 精品国产一区二区三区不卡| 欧美bbbbb| 精品福利一二区| 久久不见久久见中文字幕免费| 91精品综合久久久久久| 丝瓜av网站精品一区二区| 在线成人av影院| 日韩在线a电影| 日韩一二三区视频| 久久精品av麻豆的观看方式| 精品福利一二区| 风间由美性色一区二区三区| 国产午夜精品久久久久久免费视| 国产高清成人在线| 亚洲欧美中日韩| 欧洲一区二区三区在线| 亚洲一区二区三区中文字幕 | 欧美日韩久久不卡| 午夜电影久久久| 91精品国产一区二区三区蜜臀| 亚洲福利视频导航| 日韩欧美一级二级三级| 狠狠色狠狠色综合日日91app| 久久久精品国产免费观看同学| 国产91高潮流白浆在线麻豆| 亚洲视频香蕉人妖| 欧美日韩日日夜夜| 久久成人av少妇免费| 国产日韩精品视频一区| 在线一区二区观看| 久久国产麻豆精品| 中文字幕永久在线不卡| 欧美日韩精品一区二区三区四区 | 欧美精品久久一区二区三区| 偷拍日韩校园综合在线| 久久久久9999亚洲精品| 在线一区二区观看| 激情五月激情综合网| 亚洲人123区| 91精品在线观看入口| 国产成人综合视频| 亚洲成人中文在线| 日本一二三不卡| 欧美一区二区三区在线观看| 成人av网址在线| 美女高潮久久久| 亚洲精品国产精品乱码不99| 日韩女优视频免费观看| 日本电影亚洲天堂一区| 国产高清一区日本| 视频一区国产视频| 亚洲你懂的在线视频| 精品国产凹凸成av人导航| 欧美在线观看一二区| 成人激情文学综合网| 蜜桃av一区二区在线观看| 亚洲精品免费一二三区| 久久久精品国产免费观看同学| 欧美日韩高清在线| 91色综合久久久久婷婷| 国产精品一品视频| 激情另类小说区图片区视频区| 亚洲国产视频直播| 亚洲精品老司机| 亚洲国产成人私人影院tom| 精品免费国产一区二区三区四区| 欧美怡红院视频| 色嗨嗨av一区二区三区| 99精品欧美一区二区蜜桃免费| 国产剧情一区在线| 国产一区二区三区国产| 久久成人免费日本黄色| 免费成人小视频| 蜜桃久久久久久| 看电视剧不卡顿的网站| 麻豆精品国产传媒mv男同 | 狠狠色丁香婷综合久久| 五月激情综合色| 日本中文一区二区三区| 亚洲成人免费视频| 亚洲国产另类精品专区| 性久久久久久久| 亚洲成a人在线观看| 天天色综合成人网| 日韩中文字幕91| 日本不卡一二三| 久久精品国产999大香线蕉| 黄色小说综合网站| 国产精品2024| 成人福利在线看| 日本福利一区二区| 欧美日韩国产免费一区二区| 6080国产精品一区二区| 欧美大片一区二区| 国产无一区二区| 亚洲欧美在线aaa| 亚洲综合av网| 蜜桃av噜噜一区| 国产福利精品导航| 日本高清视频一区二区| 欧美日韩国产欧美日美国产精品| 日韩一区二区精品在线观看| 精品国产乱码久久久久久免费 | 成人一级片在线观看| 99久久伊人久久99| 欧美午夜免费电影| 欧美一区二区三区视频免费| 国产日韩欧美激情| 亚洲图片自拍偷拍| 国产精品自在在线| 日本精品一区二区三区高清| 日韩精品在线一区| 中文字幕亚洲电影| 日韩综合小视频| 成人网在线播放| 欧美三级中文字| 欧美va日韩va| 亚洲精品免费在线| 国产麻豆精品theporn| 97久久久精品综合88久久| 欧美一级日韩不卡播放免费| 中文字幕不卡的av| 日日摸夜夜添夜夜添精品视频| 国产精品资源在线观看| 欧美午夜宅男影院| 久久精品一级爱片| 日韩电影在线观看网站| 99久久精品免费看国产免费软件| 6080国产精品一区二区| 亚洲精品免费一二三区| 国产在线播放一区二区三区| 欧美日韩在线播| 国产精品美女久久久久久久网站| 欧美aaa在线|