prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Warn new users about the lazy creation of connections (when requests are expected to be served in the script fully and only)
  #### Problem Description
  The [example script](https://docs.mitmproxy.org/stable/addons-examples/#http-reply-from-proxy) for not sending any data to the server does not prevent mitmproxy from **establishing a connection** to the server.
  For which reason is said connection established when no data has to be sent to this host right away and possibly never in the future?
  I trusted mitmproxy to **not send _any_ data, as stated**, but I had to discover (the hard way) that **that's not the case**.
  I used mitmproxy in an environment where it required to stay silent, but it wasn't compliant.
  
  Could you please consider warning new users about this behavior?
  <strike>Is there an easy way to prevent establishing connections?
  Is it planned to do so on default in this case?</strike>
  *EDIT*:  Trying to prevent connections by rerouting the connection to a closed port killed the flow for the client. Routing to a different host with invalid certificate worked though, warning me in the event log and suggesting setting connection strategy to lazy and it worked.
  
  #### Steps to reproduce the behavior:
  1. Load the example script
  2. Have the client request examle.com
  3. View the event log
  
  #### System Information
  Mitmproxy: 9.0.1
  Python:    3.10.6
  OpenSSL:   OpenSSL 3.0.7 1 Nov 2022
  Platform:  Linux-5.15.0-71-generic-x86_64-with-glibc2.35
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `examples/addons/http-reply-from-proxy.py`
  Content:
  ```
  1 """Send a reply from the proxy without sending any data to the remote server."""
  2 from mitmproxy import http
  3 
  4 
  5 def request(flow: http.HTTPFlow) -> None:
  6     if flow.request.pretty_url == "http://example.com/path":
  7         flow.response = http.Response.make(
  8             200,  # (optional) status code
  9             b"Hello World",  # (optional) content
  10             {"Content-Type": "text/html"},  # (optional) headers
  11         )
  12
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/examples/addons/http-reply-from-proxy.py b/examples/addons/http-reply-from-proxy.py
  --- a/examples/addons/http-reply-from-proxy.py
  +++ b/examples/addons/http-reply-from-proxy.py
  @@ -1,4 +1,4 @@
  -"""Send a reply from the proxy without sending any data to the remote server."""
  +"""Send a reply from the proxy without sending the request to the remote server."""
   from mitmproxy import http
  
verification_info: {"golden_diff": "diff --git a/examples/addons/http-reply-from-proxy.py b/examples/addons/http-reply-from-proxy.py\n--- a/examples/addons/http-reply-from-proxy.py\n+++ b/examples/addons/http-reply-from-proxy.py\n@@ -1,4 +1,4 @@\n-\"\"\"Send a reply from the proxy without sending any data to the remote server.\"\"\"\n+\"\"\"Send a reply from the proxy without sending the request to the remote server.\"\"\"\n from mitmproxy import http\n", "issue": "Warn new users about the lazy creation of connections (when requests are expected to be served in the script fully and only)\n#### Problem Description\r\nThe [example script](https://docs.mitmproxy.org/stable/addons-examples/#http-reply-from-proxy) for not sending any data to the server does not prevent mitmproxy from **establishing a connection** to the server.\r\nFor which reason is said connection established when no data has to be sent to this host right away and possibly never in the future?\r\nI trusted mitmproxy to **not send _any_ data, as stated**, but I had to discover (the hard way) that **that's not the case**.\r\nI used mitmproxy in an environment where it required to stay silent, but it wasn't compliant.\r\n\r\nCould you please consider warning new users about this behavior?\r\n<strike>Is there an easy way to prevent establishing connections?\r\nIs it planned to do so on default in this case?</strike>\r\n*EDIT*:  Trying to prevent connections by rerouting the connection to a closed port killed the flow for the client. Routing to a different host with invalid certificate worked though, warning me in the event log and suggesting setting connection strategy to lazy and it worked.\r\n\r\n#### Steps to reproduce the behavior:\r\n1. Load the example script\r\n2. Have the client request examle.com\r\n3. View the event log\r\n\r\n#### System Information\r\nMitmproxy: 9.0.1\r\nPython:    3.10.6\r\nOpenSSL:   OpenSSL 3.0.7 1 Nov 2022\r\nPlatform:  Linux-5.15.0-71-generic-x86_64-with-glibc2.35\r\n\r\n\n", "before_files": [{"content": "\"\"\"Send a reply from the proxy without sending any data to the remote server.\"\"\"\nfrom mitmproxy import http\n\n\ndef request(flow: http.HTTPFlow) -> None:\n    if flow.request.pretty_url == \"http://example.com/path\":\n        flow.response = http.Response.make(\n            200,  # (optional) status code\n            b\"Hello World\",  # (optional) content\n            {\"Content-Type\": \"text/html\"},  # (optional) headers\n        )\n", "path": "examples/addons/http-reply-from-proxy.py"}], "after_files": [{"content": "\"\"\"Send a reply from the proxy without sending the request to the remote server.\"\"\"\nfrom mitmproxy import http\n\n\ndef request(flow: http.HTTPFlow) -> None:\n    if flow.request.pretty_url == \"http://example.com/path\":\n        flow.response = http.Response.make(\n            200,  # (optional) status code\n            b\"Hello World\",  # (optional) content\n            {\"Content-Type\": \"text/html\"},  # (optional) headers\n        )\n", "path": "examples/addons/http-reply-from-proxy.py"}]}