From e269bec1053f059ba0fd701c1e7fa1ad424726bc Mon Sep 17 00:00:00 2001 From: RaNaN Date: Thu, 12 May 2011 21:57:53 +0200 Subject: some fixes, closed #306 --- module/network/HTTPRequest.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'module/network/HTTPRequest.py') diff --git a/module/network/HTTPRequest.py b/module/network/HTTPRequest.py index f0a80fd93..598be78c7 100644 --- a/module/network/HTTPRequest.py +++ b/module/network/HTTPRequest.py @@ -34,7 +34,7 @@ class BadHeader(Exception): class HTTPRequest(): - def __init__(self, cookies=None, interface=None, proxies=None): + def __init__(self, cookies=None, options=None): self.c = pycurl.Curl() self.rep = StringIO() @@ -50,7 +50,7 @@ class HTTPRequest(): self.headers = [] #temporary request header self.initHandle() - self.setInterface(interface, proxies) + self.setInterface(options["interface"], options["proxies"], options["ipv6"]) self.c.setopt(pycurl.WRITEFUNCTION, self.write) self.c.setopt(pycurl.HEADERFUNCTION, self.writeHeader) @@ -80,7 +80,7 @@ class HTTPRequest(): "Connection: keep-alive", "Keep-Alive: 300"]) - def setInterface(self, interface, proxy): + def setInterface(self, interface, proxy, ipv6=False): if interface and interface.lower() != "none": self.c.setopt(pycurl.INTERFACE, str(interface)) @@ -98,6 +98,11 @@ class HTTPRequest(): if proxy["username"]: self.c.setopt(pycurl.PROXYUSERPWD, "%s:%s" % (proxy["username"], proxy["password"])) + if ipv6: + self.c.setopt(pycurl.IPRESOLVE, pycurl.IPRESOLVE_WHATEVER) + else: + self.c.setopt(pycurl.IPRESOLVE, pycurl.IPRESOLVE_V4) + def addCookies(self): """ put cookies from curl handle to cj """ if self.cj: -- cgit v1.2.3