當前位置: 首頁>>代碼示例>>Python>>正文


Python cookielib.http2time方法代碼示例

本文整理匯總了Python中cookielib.http2time方法的典型用法代碼示例。如果您正苦於以下問題:Python cookielib.http2time方法的具體用法?Python cookielib.http2time怎麽用?Python cookielib.http2time使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cookielib的用法示例。


在下文中一共展示了cookielib.http2time方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_http2time_garbage

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import http2time [as 別名]
def test_http2time_garbage(self):
        for test in [
            '',
            'Garbage',
            'Mandag 16. September 1996',
            '01-00-1980',
            '01-13-1980',
            '00-01-1980',
            '32-01-1980',
            '01-01-1980 25:00:00',
            '01-01-1980 00:61:00',
            '01-01-1980 00:00:62',
            ]:
            self.assertTrue(http2time(test) is None,
                         "http2time(%s) is not None\n"
                         "http2time(test) %s" % (test, http2time(test))
                         ) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:19,代碼來源:test_cookielib.py

示例2: test_http2time_garbage

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import http2time [as 別名]
def test_http2time_garbage(self):
        from cookielib import http2time

        for test in [
            '',
            'Garbage',
            'Mandag 16. September 1996',
            '01-00-1980',
            '01-13-1980',
            '00-01-1980',
            '32-01-1980',
            '01-01-1980 25:00:00',
            '01-01-1980 00:61:00',
            '01-01-1980 00:00:62',
            ]:
            self.assertTrue(http2time(test) is None,
                         "http2time(%s) is not None\n"
                         "http2time(test) %s" % (test, http2time(test))
                         ) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:21,代碼來源:test_cookielib.py

示例3: test_http2time_garbage

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import http2time [as 別名]
def test_http2time_garbage(self):
        from cookielib import http2time

        for test in [
            '',
            'Garbage',
            'Mandag 16. September 1996',
            '01-00-1980',
            '01-13-1980',
            '00-01-1980',
            '32-01-1980',
            '01-01-1980 25:00:00',
            '01-01-1980 00:61:00',
            '01-01-1980 00:00:62',
            ]:
            self.assert_(http2time(test) is None,
                         "http2time(%s) is not None\n"
                         "http2time(test) %s" % (test, http2time(test))
                         ) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:21,代碼來源:test_cookielib.py

示例4: test_http2time

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import http2time [as 別名]
def test_http2time(self):
        def parse_date(text):
            return time.gmtime(http2time(text))[:6]

        self.assertEqual(parse_date("01 Jan 2001"), (2001, 1, 1, 0, 0, 0.0))

        # this test will break around year 2070
        self.assertEqual(parse_date("03-Feb-20"), (2020, 2, 3, 0, 0, 0.0))

        # this test will break around year 2048
        self.assertEqual(parse_date("03-Feb-98"), (1998, 2, 3, 0, 0, 0.0)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:13,代碼來源:test_cookielib.py

示例5: test_http2time_formats

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import http2time [as 別名]
def test_http2time_formats(self):


        # test http2time for supported dates.  Test cases with 2 digit year
        # will probably break in year 2044.
        tests = [
         'Thu, 03 Feb 1994 00:00:00 GMT',  # proposed new HTTP format
         'Thursday, 03-Feb-94 00:00:00 GMT',  # old rfc850 HTTP format
         'Thursday, 03-Feb-1994 00:00:00 GMT',  # broken rfc850 HTTP format

         '03 Feb 1994 00:00:00 GMT',  # HTTP format (no weekday)
         '03-Feb-94 00:00:00 GMT',  # old rfc850 (no weekday)
         '03-Feb-1994 00:00:00 GMT',  # broken rfc850 (no weekday)
         '03-Feb-1994 00:00 GMT',  # broken rfc850 (no weekday, no seconds)
         '03-Feb-1994 00:00',  # broken rfc850 (no weekday, no seconds, no tz)

         '03-Feb-94',  # old rfc850 HTTP format (no weekday, no time)
         '03-Feb-1994',  # broken rfc850 HTTP format (no weekday, no time)
         '03 Feb 1994',  # proposed new HTTP format (no weekday, no time)

         # A few tests with extra space at various places
         '  03   Feb   1994  0:00  ',
         '  03-Feb-1994  ',
        ]

        test_t = 760233600  # assume broken POSIX counting of seconds
        result = time2isoz(test_t)
        expected = "1994-02-03 00:00:00Z"
        self.assertEqual(result, expected,
                         "%s  =>  '%s' (%s)" % (test_t, result, expected))

        for s in tests:
            self.assertEqual(http2time(s), test_t, s)
            self.assertEqual(http2time(s.lower()), test_t, s.lower())
            self.assertEqual(http2time(s.upper()), test_t, s.upper()) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:37,代碼來源:test_cookielib.py

示例6: test_http2time_redos_regression_actually_completes

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import http2time [as 別名]
def test_http2time_redos_regression_actually_completes(self):
        # LOOSE_HTTP_DATE_RE was vulnerable to malicious input which caused catastrophic backtracking (REDoS).
        # If we regress to cubic complexity, this test will take a very long time to succeed.
        # If fixed, it should complete within a fraction of a second.
        http2time("01 Jan 1970{}00:00:00 GMT!".format(" " * 10 ** 5))
        http2time("01 Jan 1970 00:00:00{}GMT!".format(" " * 10 ** 5)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:8,代碼來源:test_cookielib.py

示例7: test_http2time

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import http2time [as 別名]
def test_http2time(self):
        from cookielib import http2time

        def parse_date(text):
            return time.gmtime(http2time(text))[:6]

        self.assertEqual(parse_date("01 Jan 2001"), (2001, 1, 1, 0, 0, 0.0))

        # this test will break around year 2070
        self.assertEqual(parse_date("03-Feb-20"), (2020, 2, 3, 0, 0, 0.0))

        # this test will break around year 2048
        self.assertEqual(parse_date("03-Feb-98"), (1998, 2, 3, 0, 0, 0.0)) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:15,代碼來源:test_cookielib.py

示例8: test_http2time_formats

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import http2time [as 別名]
def test_http2time_formats(self):
        from cookielib import http2time, time2isoz

        # test http2time for supported dates.  Test cases with 2 digit year
        # will probably break in year 2044.
        tests = [
         'Thu, 03 Feb 1994 00:00:00 GMT',  # proposed new HTTP format
         'Thursday, 03-Feb-94 00:00:00 GMT',  # old rfc850 HTTP format
         'Thursday, 03-Feb-1994 00:00:00 GMT',  # broken rfc850 HTTP format

         '03 Feb 1994 00:00:00 GMT',  # HTTP format (no weekday)
         '03-Feb-94 00:00:00 GMT',  # old rfc850 (no weekday)
         '03-Feb-1994 00:00:00 GMT',  # broken rfc850 (no weekday)
         '03-Feb-1994 00:00 GMT',  # broken rfc850 (no weekday, no seconds)
         '03-Feb-1994 00:00',  # broken rfc850 (no weekday, no seconds, no tz)

         '03-Feb-94',  # old rfc850 HTTP format (no weekday, no time)
         '03-Feb-1994',  # broken rfc850 HTTP format (no weekday, no time)
         '03 Feb 1994',  # proposed new HTTP format (no weekday, no time)

         # A few tests with extra space at various places
         '  03   Feb   1994  0:00  ',
         '  03-Feb-1994  ',
        ]

        test_t = 760233600  # assume broken POSIX counting of seconds
        result = time2isoz(test_t)
        expected = "1994-02-03 00:00:00Z"
        self.assertEqual(result, expected,
                         "%s  =>  '%s' (%s)" % (test_t, result, expected))

        for s in tests:
            t = http2time(s)
            t2 = http2time(s.lower())
            t3 = http2time(s.upper())

            self.assertTrue(t == t2 == t3 == test_t,
                         "'%s'  =>  %s, %s, %s (%s)" % (s, t, t2, t3, test_t)) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:40,代碼來源:test_cookielib.py

示例9: test_http2time_formats

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import http2time [as 別名]
def test_http2time_formats(self):
        from cookielib import http2time, time2isoz

        # test http2time for supported dates.  Test cases with 2 digit year
        # will probably break in year 2044.
        tests = [
         'Thu, 03 Feb 1994 00:00:00 GMT',  # proposed new HTTP format
         'Thursday, 03-Feb-94 00:00:00 GMT',  # old rfc850 HTTP format
         'Thursday, 03-Feb-1994 00:00:00 GMT',  # broken rfc850 HTTP format

         '03 Feb 1994 00:00:00 GMT',  # HTTP format (no weekday)
         '03-Feb-94 00:00:00 GMT',  # old rfc850 (no weekday)
         '03-Feb-1994 00:00:00 GMT',  # broken rfc850 (no weekday)
         '03-Feb-1994 00:00 GMT',  # broken rfc850 (no weekday, no seconds)
         '03-Feb-1994 00:00',  # broken rfc850 (no weekday, no seconds, no tz)

         '03-Feb-94',  # old rfc850 HTTP format (no weekday, no time)
         '03-Feb-1994',  # broken rfc850 HTTP format (no weekday, no time)
         '03 Feb 1994',  # proposed new HTTP format (no weekday, no time)

         # A few tests with extra space at various places
         '  03   Feb   1994  0:00  ',
         '  03-Feb-1994  ',
        ]

        test_t = 760233600  # assume broken POSIX counting of seconds
        result = time2isoz(test_t)
        expected = "1994-02-03 00:00:00Z"
        self.assertEqual(result, expected,
                         "%s  =>  '%s' (%s)" % (test_t, result, expected))

        for s in tests:
            self.assertEqual(http2time(s), test_t, s)
            self.assertEqual(http2time(s.lower()), test_t, s.lower())
            self.assertEqual(http2time(s.upper()), test_t, s.upper()) 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:37,代碼來源:test_cookielib.py

示例10: test_http2time

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import http2time [as 別名]
def test_http2time(self):
        from cookielib import http2time

        def parse_date(text):
            return time.gmtime(http2time(text))[:6]

        self.assertEquals(parse_date("01 Jan 2001"), (2001, 1, 1, 0, 0, 0.0))

        # this test will break around year 2070
        self.assertEquals(parse_date("03-Feb-20"), (2020, 2, 3, 0, 0, 0.0))

        # this test will break around year 2048
        self.assertEquals(parse_date("03-Feb-98"), (1998, 2, 3, 0, 0, 0.0)) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:15,代碼來源:test_cookielib.py

示例11: test_http2time_formats

# 需要導入模塊: import cookielib [as 別名]
# 或者: from cookielib import http2time [as 別名]
def test_http2time_formats(self):
        from cookielib import http2time, time2isoz

        # test http2time for supported dates.  Test cases with 2 digit year
        # will probably break in year 2044.
        tests = [
         'Thu, 03 Feb 1994 00:00:00 GMT',  # proposed new HTTP format
         'Thursday, 03-Feb-94 00:00:00 GMT',  # old rfc850 HTTP format
         'Thursday, 03-Feb-1994 00:00:00 GMT',  # broken rfc850 HTTP format

         '03 Feb 1994 00:00:00 GMT',  # HTTP format (no weekday)
         '03-Feb-94 00:00:00 GMT',  # old rfc850 (no weekday)
         '03-Feb-1994 00:00:00 GMT',  # broken rfc850 (no weekday)
         '03-Feb-1994 00:00 GMT',  # broken rfc850 (no weekday, no seconds)
         '03-Feb-1994 00:00',  # broken rfc850 (no weekday, no seconds, no tz)

         '03-Feb-94',  # old rfc850 HTTP format (no weekday, no time)
         '03-Feb-1994',  # broken rfc850 HTTP format (no weekday, no time)
         '03 Feb 1994',  # proposed new HTTP format (no weekday, no time)

         # A few tests with extra space at various places
         '  03   Feb   1994  0:00  ',
         '  03-Feb-1994  ',
        ]

        test_t = 760233600  # assume broken POSIX counting of seconds
        result = time2isoz(test_t)
        expected = "1994-02-03 00:00:00Z"
        self.assertEquals(result, expected,
                          "%s  =>  '%s' (%s)" % (test_t, result, expected))

        for s in tests:
            t = http2time(s)
            t2 = http2time(s.lower())
            t3 = http2time(s.upper())

            self.assert_(t == t2 == t3 == test_t,
                         "'%s'  =>  %s, %s, %s (%s)" % (s, t, t2, t3, test_t)) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:40,代碼來源:test_cookielib.py


注:本文中的cookielib.http2time方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。