Commit d29bbd0c authored by Alexandre's avatar Alexandre
Browse files

[DoH] Store HTTP method in Request object (POST,HEAD)

parent cff5ba60
...@@ -187,6 +187,7 @@ class RequestDoH: ...@@ -187,6 +187,7 @@ class RequestDoH:
self.message.id = 0 # DoH requests that self.message.id = 0 # DoH requests that
self.message.flags |= dns.flags.AD # Ask for validation self.message.flags |= dns.flags.AD # Ask for validation
self.data = self.message.to_wire() self.data = self.message.to_wire()
self.post = False
self.head = False self.head = False
def check_response(self): def check_response(self):
...@@ -424,9 +425,9 @@ class ConnectionDoH(Connection): ...@@ -424,9 +425,9 @@ class ConnectionDoH(Connection):
self.reset_opt_default() self.reset_opt_default()
except AttributeError: except AttributeError:
self.create_handle() self.create_handle()
if self.post: if self.post or request.post:
self.prepare_post(request) self.prepare_post(request)
elif self.head: elif self.head or request.head:
self.prepare_head(request) self.prepare_head(request)
request.head = True request.head = True
else: else:
...@@ -438,11 +439,13 @@ class ConnectionDoH(Connection): ...@@ -438,11 +439,13 @@ class ConnectionDoH(Connection):
self.set_opt(pycurl.URL, self.server + ("?dns=%s" % dns_req)) self.set_opt(pycurl.URL, self.server + ("?dns=%s" % dns_req))
def prepare_post(self, request): def prepare_post(self, request):
request.post = True
self.set_opt(pycurl.POST, True) self.set_opt(pycurl.POST, True)
self.set_opt(pycurl.POSTFIELDS, request.data) self.set_opt(pycurl.POSTFIELDS, request.data)
self.set_opt(pycurl.URL, self.server) self.set_opt(pycurl.URL, self.server)
def prepare_head(self, request): def prepare_head(self, request):
request.head = True
self.prepare_get(request) self.prepare_get(request)
self.set_opt(pycurl.NOBODY, True) self.set_opt(pycurl.NOBODY, True)
......
Markdown is supported
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