本文整理汇总了Python中CGIHTTPServer.CGIHTTPRequestHandler方法的典型用法代码示例。如果您正苦于以下问题:Python CGIHTTPServer.CGIHTTPRequestHandler方法的具体用法?Python CGIHTTPServer.CGIHTTPRequestHandler怎么用?Python CGIHTTPServer.CGIHTTPRequestHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGIHTTPServer
的用法示例。
在下文中一共展示了CGIHTTPServer.CGIHTTPRequestHandler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import CGIHTTPRequestHandler [as 别名]
def setup(self):
"""Override SocketServer.StreamRequestHandler.setup to wrap rfile
with MemorizingFile.
This method will be called by BaseRequestHandler's constructor
before calling BaseHTTPRequestHandler.handle.
BaseHTTPRequestHandler.handle will call
BaseHTTPRequestHandler.handle_one_request and it will call
WebSocketRequestHandler.parse_request.
"""
# Call superclass's setup to prepare rfile, wfile, etc. See setup
# definition on the root class SocketServer.StreamRequestHandler to
# understand what this does.
CGIHTTPServer.CGIHTTPRequestHandler.setup(self)
self.rfile = memorizingfile.MemorizingFile(
self.rfile,
max_memorized_lines=_MAX_MEMORIZED_LINES)
示例2: is_cgi
# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import CGIHTTPRequestHandler [as 别名]
def is_cgi(self):
"""Test whether self.path corresponds to a CGI script.
Add extra check that self.path doesn't contains ..
Also check if the file is a executable file or not.
If the file is not executable, it is handled as static file or dir
rather than a CGI script.
"""
if CGIHTTPServer.CGIHTTPRequestHandler.is_cgi(self):
if '..' in self.path:
return False
# strip query parameter from request path
resource_name = self.path.split('?', 2)[0]
# convert resource_name into real path name in filesystem.
scriptfile = self.translate_path(resource_name)
if not os.path.isfile(scriptfile):
return False
if not self.is_executable(scriptfile):
return False
return True
return False
示例3: end_headers
# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import CGIHTTPRequestHandler [as 别名]
def end_headers(self):
self.send_header("Pragma", "no-cache")
self.send_header("Cache-Control", "no-cache, no-store, must-revalidate")
self.send_header("Pragma", "no-cache")
CGIHTTPServer.CGIHTTPRequestHandler.end_headers(self)
示例4: __init__
# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import CGIHTTPRequestHandler [as 别名]
def __init__(self, request, client_address, server):
self._logger = util.get_class_logger(self)
self._options = server.websocket_server_options
# Overrides CGIHTTPServerRequestHandler.cgi_directories.
self.cgi_directories = self._options.cgi_directories
# Replace CGIHTTPRequestHandler.is_executable method.
if self._options.is_executable_method is not None:
self.is_executable = self._options.is_executable_method
# This actually calls BaseRequestHandler.__init__.
CGIHTTPServer.CGIHTTPRequestHandler.__init__(
self, request, client_address, server)
示例5: __init__
# 需要导入模块: import CGIHTTPServer [as 别名]
# 或者: from CGIHTTPServer import CGIHTTPRequestHandler [as 别名]
def __init__(self, req, client_addr, server):
CGIHTTPServer.CGIHTTPRequestHandler.__init__(self, req, client_addr, server)