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).
0
votes
Does it have to be the Python Standard Library? Is a 3rd-party library appropriate?
- James Mills
This configuration implies that the server is on the other end of a link directly connected to the host you want to run the HTTP GET request from. Is that the case? Can you describe the network configuration more completely? Why doesn't the host's normal routing policy handle this for you?
- Jean-Paul Calderone
1 Answers
1
votes
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
$