0

我正在尝试开发一个 HTTPS 代理,以便将请求重定向到 https,如下所示:

requests.get('https://page', proxies=dict(https='localhost:4000'))

为了做到这一点,我有以下代码:

import http.server, ssl

from settings import SOCKS_TYPE, SOCKS_CACHE_URL

class MyProxy(http.server.SimpleHTTPRequestHandler):
    def do_GET(self):
        http.server.SimpleHTTPRequestHandler.do_GET(self)
        url=self.path
        self.send_response(200)
        self.end_headers()
        print('a')

server_address = ('127.0.0.1', 4000)
httpd = http.server.HTTPServer(server_address, MyProxy)
httpd.socket = ssl.wrap_socket(httpd.socket,
                               server_side=True,
                               certfile='./cacert.pem',
                               keyfile='./private.pem',
                               ssl_version=ssl.PROTOCOL_TLS)

print ("SocksProxt runing on port: ", str(4000))

httpd.serve_forever()

当我执行此操作时,永远无法访问 do_GET,并且我无法打印(a),我有另一个逻辑但它没有放在那里。

如何在此服务器上捕获 GET 请求?

谢谢

4

0 回答 0