Commit cd2a40c3 authored by Alexandre's avatar Alexandre
Browse files

[DoH] Check responses as they arrive with HTTP/2 streams

parent 4dc02af2
......@@ -528,6 +528,9 @@ class ConnectionDoH(Connection):
continue
while 1:
ret, num_handles = self.multi.perform()
n, handle_pass, handle_fail = self.multi.info_read()
for handle in handle_pass:
self.read_result_handle(handle)
if ret != pycurl.E_CALL_MULTI_PERFORM:
break
......@@ -558,6 +561,15 @@ class ConnectionDoH(Connection):
self.send(handle)
self.receive(handle)
def read_result_handle(self, handle):
self.receive(handle)
handle.request.check_response()
print("Return code %s:\n%s\n" % (handle.request.rcode, handle.request.response))
def read_results(self):
for handle in self.all_handles:
self.read_result_handle(handle)
def do_test(self, request, synchronous=True):
if synchronous:
handle = self.curl_handle
......@@ -627,12 +639,6 @@ def print_result(connection, request, prefix=None, display_err=True):
ok = False
return ok
def read_results(connection):
for handle in connection.all_handles:
connection.receive(handle)
handle.request.check_response()
print("Return code %s:\n%s\n" % (handle.request.rcode, handle.request.response))
def create_request(qname, qtype=rtype, use_edns=edns, want_dnssec=dnssec, dot=dot, trunc=False):
if dot:
request = RequestDoT(qname, rtype, use_edns, want_dnssec)
......@@ -1044,8 +1050,9 @@ for connectTo in ip_set:
time.sleep(delay)
if multistreams:
conn.perform_multi()
print()
read_results(conn)
if False:
print()
conn.read_results()
else:
ok = run_check(conn) and ok # need to run run_check first
stop = time.time()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment