Python CGIHTTPServer.CGIHTTPRequestHandler() Examples

The following are 6 code examples of CGIHTTPServer.CGIHTTPRequestHandler(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module CGIHTTPServer , or try the search function .
Example #1
Source File: standalone.py    From pywebsocket with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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) 
Example #2
Source File: standalone.py    From pywebsocket with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 
Example #3
Source File: run.py    From CVE-2014-4377 with MIT License 5 votes vote down vote up
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) 
Example #4
Source File: run.py    From CVE-2014-4378 with MIT License 5 votes vote down vote up
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) 
Example #5
Source File: standalone.py    From pywebsocket with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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) 
Example #6
Source File: server.py    From TwinGAN with Apache License 2.0 5 votes vote down vote up
def __init__(self, req, client_addr, server):
    CGIHTTPServer.CGIHTTPRequestHandler.__init__(self, req, client_addr, server)