Is this a copy/paste of the code in basicproxy.cpp and stateful_proxy.cpp?  Can we commonize?