aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod/pathod.py
blob: c700b550f30be5732a9cb6f9cae869cb5584f8e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from netlib import tcp, protocol, odict

class PathodHandler(tcp.BaseHandler):
    def handle(self):
        line = self.rfile.readline()
        if line == "\r\n" or line == "\n": # Possible leftover from previous message
            line = self.rfile.readline()
        if line == "":
            return None

        method, path, httpversion = protocol.parse_init_http(line)
        headers = odict.ODictCaseless(protocol.read_headers(self.rfile))
        content = protocol.read_http_body_request(
                    self.rfile, self.wfile, headers, httpversion, None
                )
        print method, path, httpversion
        #return flow.Request(client_conn, httpversion, host, port, "http", method, path, headers, content)


class Pathod(tcp.TCPServer):
    def __init__(self, addr):
        tcp.TCPServer.__init__(self, addr)

    def handle_connection(self, request, client_address):
        PathodHandler(request, client_address, self)