I am writing fuzzer for a Flask application. I have examples of requests stored as text files, for example, get.txt:
GET /docs/index.html HTTP/1.1
Host: www.w3.org
Ideally, I would parse this with an object werkzeug.wrappers.Request
, something like this (psuedo-code):
from werkzeug.wrappers import Request
req = Request()
with open('get.txt') as f:
req.parse_raw(f.read())
However, it seems that raw HTTP analysis does not occur in Werkzeug. Instead, Werkzeug takes the WSGI environment from BaseHTTPServer.BaseHTTPRequestHandler , and it requires BaseHTTPServer.HTTPServer to parse the request. This seems to be too complicated.
I also met http-parser , which is closer to what I want, but it duplicates most Werkzeug data structures with incompatible types. I would have to convert data from one to another.
HTTP- WSGI- Werkzeug ( BaseHTTPRequestHandler HTTP-)?