I am looking for a recipe for writing and reading the raw data generated by a requests transaction from files rather than a socket. By "raw data" I mean the bytes just before they are written to or read from the underlying socket. I've tried:

Using "hooks". This seems to be mostly deprecated as the only remaining hook is "response".
mount()ing a custom Adapter. Some aggressive duck-typing here provides access to the underlying httplib.HTTPConnection objects, but the call stack down there is complicated and quite brittle.

The final solution does not need to be general-purpose as I am only interested in vanilla HTTP functionality. I won't be streaming or using the edgier parts of the protocol.
Thanks!
Spawn a thread (import threading).  Run an HTTP server in there.  You can generate a unique port on demand by socket.socket().bind(0).  In the HTTP server, just write the incoming data to a file (perhaps named by timestamp and incoming port number).  Then send your requests there.
Perofrming a python-requests Request/Reponse transaction using files rather than a socket