-
-
Notifications
You must be signed in to change notification settings - Fork 617
Description
Is your feature request related to a problem? Please describe.
This is a requirement to serve responses out of cache. See #441 and #442 for some background. In short, when cache plugin is enabled along with TLS interception, plugin avoids upstream connection altogether, returning responses from the cache if found.
Problem If client pipelines requests over connected tunnel (which usually is the case), there will be cases where 1st tunneled request is found in cache, but 2nd tunneled request is not in cache. Resulting into reconnection with the upstream. Designing for this flow can be a PITA.
Describe the solution you'd like
Modify core server code to work without an upstream server connection (at-least when TLS interception is ON). Currently, server throws following exception if a plugin avoids upstream CONNECT connection.
Exception while handling connection <socket.socket fd=16, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=0, laddr=('::1', 8899, 0, 0), raddr=('::1', 56599, 0, 0)>
Traceback (most recent call last):
File "/Users/abhinavsingh/Dev/proxy.py/proxy/http/handler.py", line 353, in run
teardown = self.run_once()
File "/Users/abhinavsingh/Dev/proxy.py/proxy/http/handler.py", line 338, in run_once
teardown = self.handle_events(readables, writables)
File "/Users/abhinavsingh/Dev/proxy.py/proxy/http/handler.py", line 152, in handle_events
teardown = self.handle_readables(readables)
File "/Users/abhinavsingh/Dev/proxy.py/proxy/http/handler.py", line 298, in handle_readables
upgraded_sock = plugin.on_request_complete()
File "/Users/abhinavsingh/Dev/proxy.py/proxy/http/proxy/server.py", line 350, in on_request_complete
self.wrap_server()
File "/Users/abhinavsingh/Dev/proxy.py/proxy/http/proxy/server.py", line 518, in wrap_server
assert self.server is not None
AssertionError