Commit e1d4ff7e authored by Alexandre's avatar Alexandre
Browse files

Merge branch 'test-mime_type' into option-check

parents fecd969e 9e71faf1
......@@ -551,7 +551,7 @@ def print_result(connection, request, prefix=None):
return ok
def run_check(connection):
def run_check_default(connection):
ok = True
req_args = { 'qname': name, 'qtype': rtype, 'use_edns': edns, 'want_dnssec': dnssec }
requests = create_requests_list(dot=dot, **req_args)
......@@ -579,6 +579,42 @@ def run_check(connection):
break
return ok
def run_check_mime(connection, accept="application/dns-message", content_type="application/dns-message"):
if dot:
return True
ok = True
header = [f"Accept: {accept}", f"Content-type: {content_type}"]
req_args = { 'qname': name, 'qtype': rtype, 'use_edns': edns, 'want_dnssec': dnssec }
request = create_request(**req_args)
connection.curl.setopt(pycurl.HTTPHEADER, header)
try:
connection.send_and_receive(request)
except CustomException as e:
ok = False
error(e)
request.check_response()
if not print_result(connection, request, prefix=f"Test Header {', '.join(header)}"):
ok = False
default = "application/dns-message"
default_header = [f"Accept: {default}", f"Content-type: {default}"]
connection.curl.setopt(pycurl.HTTPHEADER, default_header)
return ok
def run_check_additionals(connection):
if not run_check_mime(connection, accept="text/html"):
return False
if not run_check_mime(connection, content_type="text/html"):
return False
return True
def run_check(connection):
if not run_check_default(connection):
return False
if not run_check_additionals(connection):
return False
return True
# Main program
me = os.path.basename(sys.argv[0])
monitoring = (me == "check_doh" or me == "check_dot")
......
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