当前位置: 首页>>代码示例>>Python>>正文


Python CGIHTTPServer._url_collapse_path_split方法代码示例

本文整理汇总了Python中CGIHTTPServer._url_collapse_path_split方法的典型用法代码示例。如果您正苦于以下问题:Python CGIHTTPServer._url_collapse_path_split方法的具体用法?Python CGIHTTPServer._url_collapse_path_split怎么用?Python CGIHTTPServer._url_collapse_path_split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGIHTTPServer的用法示例。


在下文中一共展示了CGIHTTPServer._url_collapse_path_split方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_url_collapse_path_split

# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import _url_collapse_path_split [as 别名]
 def test_url_collapse_path_split(self):
     test_vectors = {
         "": ("/", ""),
         "..": IndexError,
         "/.//..": IndexError,
         "/": ("/", ""),
         "//": ("/", ""),
         "/\\": ("/", "\\"),
         "/.//": ("/", ""),
         "cgi-bin/file1.py": ("/cgi-bin", "file1.py"),
         "/cgi-bin/file1.py": ("/cgi-bin", "file1.py"),
         "a": ("/", "a"),
         "/a": ("/", "a"),
         "//a": ("/", "a"),
         "./a": ("/", "a"),
         "./C:/": ("/C:", ""),
         "/a/b": ("/a", "b"),
         "/a/b/": ("/a/b", ""),
         "/a/b/c/..": ("/a/b", ""),
         "/a/b/c/../d": ("/a/b", "d"),
         "/a/b/c/../d/e/../f": ("/a/b/d", "f"),
         "/a/b/c/../d/e/../../f": ("/a/b", "f"),
         "/a/b/c/../d/e/.././././..//f": ("/a/b", "f"),
         "../a/b/c/../d/e/.././././..//f": IndexError,
         "/a/b/c/../d/e/../../../f": ("/a", "f"),
         "/a/b/c/../d/e/../../../../f": ("/", "f"),
         "/a/b/c/../d/e/../../../../../f": IndexError,
         "/a/b/c/../d/e/../../../../f/..": ("/", ""),
     }
     for path, expected in test_vectors.iteritems():
         if isinstance(expected, type) and issubclass(expected, Exception):
             self.assertRaises(expected, CGIHTTPServer._url_collapse_path_split, path)
         else:
             actual = CGIHTTPServer._url_collapse_path_split(path)
             self.assertEqual(expected, actual, msg="path = %r\nGot:    %r\nWanted: %r" % (path, actual, expected))
开发者ID:uestcheng,项目名称:odoo,代码行数:37,代码来源:test_httpservers.py

示例2: is_cgi

# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import _url_collapse_path_split [as 别名]
 def is_cgi(self):
     path = self.path
     i = path.rfind("?")
     if i >= 0:
         path, query = path[:i], path[i:]
     else:
         query = ""
     root, ext = os.path.splitext(path)
     if self.is_cgi_extension(ext):
         self.cgi_info = CGIHTTPServer._url_collapse_path_split(self.path)
         return True
     return False
开发者ID:pekepeke,项目名称:tinyhttp-app,代码行数:14,代码来源:tinyhttp.py

示例3: is_cgi

# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import _url_collapse_path_split [as 别名]
 def is_cgi(self):
     splitpath = CGIHTTPServer._url_collapse_path_split(self.path)
     script_query = splitpath[1].split("?", 1)
     if script_query[0].endswith(".py"):
         if splitpath[0].startswith("/"):
             # Workaround for some weirdness with how CGIHTTPServer
             # computes the SCRIPT_NAME environment variable.
             splitpath = list(splitpath)
             splitpath[0] = ''
             splitpath = tuple(splitpath)
         self.cgi_info = splitpath
         return True
     return False
开发者ID:jfly,项目名称:stackmat,代码行数:15,代码来源:test_server.py

示例4: test_url_collapse_path_split

# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import _url_collapse_path_split [as 别名]
 def test_url_collapse_path_split(self):
     test_vectors = {
         '': ('/', ''),
         '..': IndexError,
         '/.//..': IndexError,
         '/': ('/', ''),
         '//': ('/', ''),
         '/\\': ('/', '\\'),
         '/.//': ('/', ''),
         'cgi-bin/file1.py': ('/cgi-bin', 'file1.py'),
         '/cgi-bin/file1.py': ('/cgi-bin', 'file1.py'),
         '/cgi-bin/file1.py/PATH-INFO': ('/cgi-bin', 'file1.py/PATH-INFO'),
         'a': ('/', 'a'),
         '/a': ('/', 'a'),
         '//a': ('/', 'a'),
         './a': ('/', 'a'),
         './C:/': ('/C:', ''),
         '/a/b': ('/a', 'b'),
         '/a/b/': ('/a/b', ''),
         '/a/b/c/..': ('/a/b', ''),
         '/a/b/c/../d': ('/a/b', 'd'),
         '/a/b/c/../d/e/../f': ('/a/b/d', 'f'),
         '/a/b/c/../d/e/../../f': ('/a/b', 'f'),
         '/a/b/c/../d/e/.././././..//f': ('/a/b', 'f'),
         '../a/b/c/../d/e/.././././..//f': IndexError,
         '/a/b/c/../d/e/../../../f': ('/a', 'f'),
         '/a/b/c/../d/e/../../../../f': ('/', 'f'),
         '/a/b/c/../d/e/../../../../../f': IndexError,
         '/a/b/c/../d/e/../../../../f/..': ('/', ''),
     }
     for path, expected in test_vectors.iteritems():
         if isinstance(expected, type) and issubclass(expected, Exception):
             self.assertRaises(expected,
                               CGIHTTPServer._url_collapse_path_split, path)
         else:
             actual = CGIHTTPServer._url_collapse_path_split(path)
             self.assertEqual(expected, actual,
                              msg='path = %r\nGot:    %r\nWanted: %r' %
                              (path, actual, expected))
开发者ID:ilovesoup,项目名称:jython,代码行数:41,代码来源:test_httpservers.py


注:本文中的CGIHTTPServer._url_collapse_path_split方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。