In Python, Issue A Get Request To A Ipv6 Link-local Address
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 em
Solution 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
defmain(reactor, address, uri):
server = TCP6ClientEndpoint(reactor, address, 80)
agent = ProxyAgent(server, reactor)
getting = agent.request(b"GET", uri)
defgot(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 ::1http://example.com/
Got 200$
Post a Comment for "In Python, Issue A Get Request To A Ipv6 Link-local Address"