Esempio n. 1
0
    def handle_read(self):
        # Read data in buffer
        SecureServerCommunicator.handle_read(self)

        # Fetch the Http request from parent communicator
        if (self.http_communicator is None) and (len(
                self.communicator.http_history) > 0):
            self.http_communicator = self.communicator.http_history.pop(0)

            if self.http_communicator.path in Config.force_buffering:
                Logger.debug("Force buffering : " +
                             self.http_communicator.path)
                self.http.force_full_buffering = True

        if not self.http.is_ready():
            # Parse it until ready
            if self.make_http_message():
                # Now it is ready
                self._buffer = self.process()  # Stream it
                self.http_communicator = None
        else:
            # Data is streamed "on-the-fly"
            self._buffer = self._buffer  # Stream it

        if self.http.is_complete():
            self.http = HttpMessage(self)
Esempio n. 2
0
 def __init__(self, sock, ctrl=None, ssl_ctx=None):
     self.f_ctrl = ctrl
     self.ssl_ctx = ssl_ctx
     self.http = HttpMessage(self)
     self.http_history = []
     self.last_service = None
     SSLCommunicator.__init__(self, sock)
 def HandleRequest(self):
     try:
         (clientsocket, address) = self.network.serversocket.accept()
         print(address)
     except Exception as e:
         print("socket accept failed" + e)
         return
     httpMessage = HttpMessage(clientsocket)
     httpMessage.Print()
     data = self.HandleMessage(httpMessage)
     clientsocket.sendall(data.encode())
     clientsocket.shutdown(SHUT_WR)
Esempio n. 4
0
    def __init__(self, remote, ctrl, communicator=None):
        (addr, self.ssl_ctx) = remote
        self.f_ctrl = ctrl
        self.http = HttpMessage(self)
        self.http_communicator = None
        SecureServerCommunicator.__init__(self,
                                          addr,
                                          communicator=communicator)

        self.parent_http = None
        if communicator is not None:
            self.parent_http = self.communicator.http
Esempio n. 5
0
    def display_err_page(self, page_path, communicator):
        """
		Display page different than requested
		"""
        send_buffer = open(page_path, 'r').read()

        page = HttpMessage()
        page.set_header('HTTP/1.1', '200 OK')
        page.set_header('Location', '/')
        page.set_header('Content-Type', 'text/html')
        page.set_body(send_buffer)
        communicator.send(page.show())
Esempio n. 6
0
    def handle_read(self):
        if self.http.is_body():
            if self._buffer == '':
                self.http = HttpMessage()
                self.fragmented = False
            else:
                if not self.fragmented:
                    return

        super(HttpMetaCommunicator, self).handle_read()
        if self.make_http_message() is not None:
            self._buffer = self.process()
            self.fragmented = False
            return

        # The packet seams to be fragmented
        self.fragmented = True
Esempio n. 7
0
    def handle_read(self, data=None):
        if data is None:
            # Read data from socket
            SSLCommunicator.handle_read(self)
        else:
            # Data has already been read by ProtocolDetectDispatcher
            self._buffer = data

        if not self.http.is_ready():
            # Parse it until ready
            if self.make_http_message():
                # Now it is ready
                self.http_history.append(
                    self.http)  # Push http object in history
                self._buffer = self.process()  # Stream it
        else:
            # Data is streamed "on-the-fly"
            self._buffer = self._buffer  # Stream it

        if self.http.is_complete():
            self.http = HttpMessage(self)
Esempio n. 8
0
 def __init__(self):
     super(HttpMetaCommunicator, self).__init__()
     self.http = HttpMessage()
Esempio n. 9
0
 def __init__(self, addr, ctrl, communicator=None):
     self.f_ctrl = ctrl
     self.http = HttpMessage(self)
     self.http_communicator = None
     ServerCommunicator.__init__(self, addr, communicator=communicator)