Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create insertion points in a HTTP raw request
import copy
class GetInsertionPoints:
def __init__(self, request):
self.request = request
self.requests = []
self.params(append=True)
self.body(append=True)
def params(self, append: bool = False) -> None:
if self.request.params:
for q in self.request.params:
request = copy.deepcopy(self.request)
if append:
request.params[q] = str(request.params[q])+" teyascan"
else:
request.params[q] = "teyascan"
request.insertion = q
request.iplace = 'params'
self.requests.append(request)
def body(self, append: bool = False) -> None:
if self.request.data:
for q in self.request.data:
request = copy.deepcopy(self.request)
if append:
request.data[q] = str(request.data[q])+" teyascan"
else:
request.data[q] = "teyascan"
request.insertion = q
request.iplace = 'body'
self.requests.append(request)
with open("requests.txt", "rb") as f:
parser = RequestParser(f.read())
print(parser.request.method) # prints method
print(parser.request.path) # prints request.path
print(parser.request.headers) # prints requests headers
print(parser.request.data) # prints requests body
print(parser.request.params) # prints requests params
i_p = GetInsertionPoints(parser.request)
print(i_p.requests)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment