0

I am reading an early version of goagent, I don't know where is the do_CONNECT method being called.

class GaeProxyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
    ...
    def do_CONNECT(self):
        ...

The same method in the following page does not being called, either. click here

Yes, if you search "do_CONNECT", you will get almost nothing, but to search "http method CONNECT"

4

2 回答 2

1

GaeProxyHandler的基类是BaseHTTPRequestHandler,所以代码可以写成BaseHTTPRequestHandler

如果要运行代理,则应运行以下代码:

server = LocalProxyServer((common.LISTEN_IP, common.LISTEN_PORT), GAEProxyHandler)
server.serve_forever()

所以你知道服务器本身现在可能会编写关于调用方法 do_CONNECT 的代码。

让我们看看回溯,它确实如此。

  File "E:\Python33\lib\threading.py", line 616, in _bootstrap
    self._bootstrap_inner()
  File "E:\Python33\lib\threading.py", line 639, in _bootstrap_inner
    self.run()
  File "E:\Python33\lib\threading.py", line 596, in run
    self._target(*self._args, **self._kwargs)
  File "E:\Python33\lib\socketserver.py", line 610, in process_request_thread
    self.finish_request(request, client_address)
  File "E:\Python33\lib\socketserver.py", line 345, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "E:\Python33\lib\socketserver.py", line 666, in __init__
    self.handle()
  File "E:\Python33\lib\http\server.py", line 400, in handle
    self.handle_one_request()
  File "E:\Python33\lib\http\server.py", line 388, in handle_one_request
    method()
  File "E:\eclipse\workspace\GoAgent\src\goagent-local\proxy.py", line 1758, in **do_CONNECT**

看到最后一个do_CONNECT了吗?

于 2013-09-01T16:59:29.083 回答
1

CONNECT 是一种类似于 GET 或 POST 的方法,用于客户端告诉代理服务器他们需要在向 REAL 服务器发送请求之前完成 ssl 握手。

因此,当需要转发 https 请求时,将调用 do_CONNECT。

检查这个

于 2015-08-28T21:35:30.863 回答