Addon intercepting request and responding to it

Hi,

I’m trying to write an addon and want to reply to a request in the request function here. How do I intercept this request and respond to it as if I am the server my device wants to connect too. The functionality I’m looking for is something like the below

def request(self, flow):
  resp = http.HTTPResponse(
        http_version=b"HTTP/2.0",
        status_code=200,
        reason=b'OK',
        headers=flow.request.headers,
        content=the content I want to send to my device
    )
    flow.reply.send(resp)

However I can’t find anything like this. Any information would be helpful.

I figured out how to do it. So if anyone else runs into this issue. Its not reply its response so this example above would look like

def request(self, flow):
  flow.intercept()
  resp = http.HTTPResponse(
      http_version=b"HTTP/2.0",
      status_code=200,
      reason=b'OK',
      headers=flow.request.headers,
      content=content I want to send to my device
   )
   flow.response = resp
   flow.resume()

Thanks a lot, your answer helped me, I didn’t know flow.intercept() and flow.resume() existed and they solve my use case, thanks!