in plugins/traffic_dump/post_process.py [0:0]
def verify_transaction(transaction, fabricate_proxy_requests=False):
""" Function to verify that a transaction looks complete.
Args:
transaction (json object)
fabricate_proxy_requests (bool) Whether the post-processor should
fabricate proxy requests if they don't exist because the proxy served
the response locally.
Raises:
VerifySessionError if there is no transaction.
VerifyRequestError if there is a problem with a request.
VerifyResponseError if there is a problem with a response.
"""
if not transaction:
raise VerifySessionError('No transaction found in the session.')
if "client-request" not in transaction:
raise VerifyRequestError('client-request not found in transaction')
else:
verify_request(transaction["client-request"])
if "proxy-request" not in transaction and fabricate_proxy_requests:
if "proxy-response" not in transaction:
raise VerifyRequestError('proxy-response not found in transaction with a client-request')
transaction["proxy-request"] = transaction["client-request"]
if "server-response" not in transaction:
transaction["server-response"] = transaction["proxy-response"]
# proxy-response nodes can be empty.
if "proxy-response" not in transaction:
raise VerifyResponseError('proxy-response not found in transaction')
if "proxy-request" in transaction or "server-response" in transaction:
# proxy-request nodes can be empty, so no need to verify_response.
if "proxy-request" not in transaction:
raise VerifyRequestError('proxy-request not found in transaction')
if "server-response" not in transaction:
raise VerifyResponseError('server-response not found in transaction')
else:
verify_response(transaction["server-response"])