74 |
if is_ip(host): |
if is_ip(host): |
75 |
req.ip = host |
req.ip = host |
76 |
self._queue_request(req) |
self._queue_request(req) |
77 |
elif straw.config.proxy_config.use: |
elif straw.Config.get_instance().proxy_config.use: |
78 |
self._queue_request(req) |
self._queue_request(req) |
79 |
else: |
else: |
80 |
try: |
try: |
100 |
req.consumer.http_failed("Host name lookup failed") |
req.consumer.http_failed("Host name lookup failed") |
101 |
|
|
102 |
def poll(self, timeout=0.1): |
def poll(self, timeout=0.1): |
103 |
|
config = straw.Config.get_instance() |
104 |
# activate up to MAX_CONNECTIONS channels |
# activate up to MAX_CONNECTIONS channels |
105 |
while self._queue and len(asyncore.socket_map) < straw.NetworkConstants.MAX_CONNECTIONS and not straw.config.proxy_config.is_waiting: |
while self._queue and len(asyncore.socket_map) < straw.NetworkConstants.MAX_CONNECTIONS and not config.proxy_config.is_waiting: |
106 |
req = self._queue.pop(0) |
req = self._queue.pop(0) |
107 |
# has the user switched off the proxy after this request was queued |
# has the user switched off the proxy after this request was queued |
108 |
if (not straw.config.proxy_config.use) and (not req.ip): |
if (not config.proxy_config.use) and (not req.ip): |
109 |
straw.lookup_manager.lookup(req.host, self._request_resolved, req) |
straw.lookup_manager.lookup(req.host, self._request_resolved, req) |
110 |
else: |
else: |
111 |
self.do_request(req) |
self.do_request(req) |
129 |
|
|
130 |
def do_request(self, req): |
def do_request(self, req): |
131 |
proxy = None |
proxy = None |
132 |
pc = straw.config.proxy_config |
pc = straw.Config.get_instance().proxy_config |
133 |
if pc.use: |
if pc.use: |
134 |
proxy = pc.ip |
proxy = pc.ip |
135 |
if pc.use_authentication: |
if pc.use_authentication: |