Closed sandrich closed 1 month ago
Likely an issue with your local environment. I took your code, pasted it in a file, started the server, tried curl -x
to use proxy server and all seems to be working as expected.
$ python issue1412.py
─╯
2024-05-21 14:22:38,578 - pid:49817 [I] plugins.load:89 - Loaded plugin proxy.http.proxy.HttpProxyPlugin
2024-05-21 14:22:38,578 - pid:49817 [I] plugins.load:89 - Loaded plugin proxy.http.server.HttpWebServerPlugin
2024-05-21 14:22:38,578 - pid:49817 [I] plugins.load:89 - Loaded plugin proxy.http.server.reverse.ReverseProxy
2024-05-21 14:22:38,578 - pid:49817 [I] plugins.load:89 - Loaded plugin __main__.FsProxyPlugin
{b'host': (b'Host', b'google.com:443'), b'user-agent': (b'User-Agent', b'curl/8.4.0'), b'proxy-connection': (b'Proxy-Connection', b'Keep-Alive')}
2024-05-21 14:22:42,686 - pid:49827 [I] server.access_log:388 - 127.0.0.1:54018 - CONNECT google.com:443 - 7671 bytes - 498.72ms
$ cat issue1412.py
from typing import Optional
import proxy
from proxy.http.proxy import HttpProxyBasePlugin
from proxy.http.parser import HttpParser
class FsProxyPlugin(HttpProxyBasePlugin):
def before_upstream_connection(
self,
request: HttpParser,
) -> Optional[HttpParser]:
print(request.headers)
return request
if __name__ == "__main__":
with proxy.Proxy(
input_args=["--threaded", "--enable-reverse-proxy"],
enable_web_server=True,
port=8080,
plugins=[FsProxyPlugin],
) as _:
proxy.sleep_loop()
thanks @abhinavsingh . Indeed it seems to be an env issue. Worked on a different system.
I try to implement a plugin for proxy.py but for
HttpProxyBasePlugin
I cannot get any function to be executed (before_upstream_connection as an example). I'd expect a print statement to be shown in the output.If I use
ReverseProxyBasePlugin
instead, then I get the print statement. What am I missing?