Currently, the headers send in do_request method are set to either be empty (no headers are being sent) or just the 'Authorization' or 'auth' header.
Zabbix requires the 'Content-Type' header:
And this header was being included in the default session headers, but inside the do_request method the session headers are getting unintentionally overwritten by headers dict that is initialized to being empty:
headers = {}
and later modified to include either 'Authorization' or 'auth':
if self.version and self.version >= ZABBIX_6_4_0: headers["Authorization"] = f"Bearer {self.auth}" else: payload["auth"] = self.auth
after which we are making the request and unintentionally overwriting the default headers in post method parameter's:
resp = self.session.post( self.url, json=payload, headers=headers, timeout=self.timeout, )
Resulting with empty headers or not enough headers being sent.
To address this issue, my change ensures that the default headers are preserved while also incorporating the additional headers created in the do_request method.
Currently, the headers send in do_request method are set to either be empty (no headers are being sent) or just the 'Authorization' or 'auth' header. Zabbix requires the 'Content-Type' header:
And this header was being included in the default session headers, but inside the do_request method the session headers are getting unintentionally overwritten by headers dict that is initialized to being empty:
headers = {}
and later modified to include either 'Authorization' or 'auth':if self.version and self.version >= ZABBIX_6_4_0: headers["Authorization"] = f"Bearer {self.auth}" else: payload["auth"] = self.auth
after which we are making the request and unintentionally overwriting the default headers in post method parameter's:resp = self.session.post( self.url, json=payload, headers=headers, timeout=self.timeout, )
Resulting with empty headers or not enough headers being sent.To address this issue, my change ensures that the default headers are preserved while also incorporating the additional headers created in the do_request method.