Is there a standard way to issue an HTTP GET request to a url using any standard python library, with the major caveat that the host address is an ipv6 link-local address (heavy emphasis on "link-local")? The target machine that is running the server does not have any ip address other than the raw link-local ip address that includes the mac address (hence it can only be reached by an address that looks something like "fe80:::%eth0" where "%eth0" is the network interface on the client that shares a broadcast domain with the server).
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can do this with Twisted's HTTP client API:
from __future__ import print_function
from sys import argv
from twisted.internet.endpoints import TCP6ClientEndpoint
from twisted.web.client import ProxyAgent
from twisted.internet.task import react
def main(reactor, address, uri):
server = TCP6ClientEndpoint(reactor, address, 80)
agent = ProxyAgent(server, reactor)
getting = agent.request(b"GET", uri)
def got(response):
print("Got {}".format(response.code))
getting.addCallback(got)
return getting
if __name__ == "__main__":
react(main, argv[1:])
For example:
$ python http-proxy-get.py ::1 http://example.com/
Got 200
$