forked from MITRECND/htpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
35 lines (28 loc) · 841 Bytes
/
test.py
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
26
27
28
29
30
31
32
33
34
35
import htpy
def uri_callback(cp):
uri = cp.get_uri()
if "path" in uri:
print(uri["path"])
return htpy.HTP_OK
def request_headers_callback(cp):
host = cp.get_request_header("Host")
if host:
print(host)
return htpy.HTP_OK
def request_body_data_callback(data, length):
if not data is None:
print(data)
return htpy.HTP_OK
def request_complete_callback(cp):
print("Request complete.")
print(cp.get_all_request_headers())
return htpy.HTP_OK
print(htpy.HTPY_VERSION)
cp = htpy.init()
cp.register_request_uri_normalize(uri_callback)
cp.register_request_headers(request_headers_callback)
cp.register_request_body_data(request_body_data_callback)
cp.register_request_complete(request_complete_callback)
with open("request.txt", "rb") as f:
req = f.read()
cp.req_data(req)