Print HTTPFlow to do further processing

Hello everyone,

I am trying to read in the requests from a flow and put them out to a file as well as send them to a java program for more processing. I had no issue getting the requests and parsing those, however, I’m not sure how to print out the body of the response object. I’ve read the HTTPResponse documentation but didn’t see anything that would allow me to view and manipulate the body directly.
I’ve tried ctx.log.info(flow.response.content), ctx.log.info(flow.response.text) and several other variants of this but I’m not sure how to handle this object for my needs. This could also just be my lack of python knowledge.

Apologies if this is a very basic question but I’ve been going through the documentation but I’ve been unable to figure out how to do this. Thanks!

Hi, try flow.response.get_text()
ctx.log.info(flow.response.get_text())

FWIW, the API is described at http://docs.mitmproxy.org/en/stable/scripting/api.html.

My parameters also changed where I am now looking for the request body, however, I was still facing the same issue.
I’m not sure the exact difference between all of the text methods but this one ended up working out for me:
flow.request.content.decode()

I also took a lot from this example: