@@ -80,7 +80,7 @@ def __init_typed_record(self) -> TypedPDNSRecord:
8080 # Accordingly to the specs, the type can be a string OR an int. we normalize to str
8181 rrtype : str = RdataType (self ._raw_record ['rrtype' ]).name
8282 else :
83- rrtype = RdataType [self ._raw_record ['rrtype' ]].name
83+ rrtype = RdataType [self ._raw_record ['rrtype' ]. upper () ].name
8484
8585 if not isinstance (self ._raw_record ['rdata' ], (str , list )):
8686 raise PDNSRecordTypeError ('rdata' , 'str, list of string' , self ._raw_record ["rdata" ])
@@ -266,6 +266,7 @@ class PyPDNS:
266266 def __init__ (self , url : str = 'https://www.circl.lu/pdns/query' ,
267267 basic_auth : tuple [str , str ] | None = None ,
268268 auth_token : str | None = None ,
269+ auth_header : tuple [str , str ] | None = None ,
269270 enable_cache : bool = False , cache_expire_after : int = 604800 ,
270271 cache_file : str = '/tmp/pdns.cache' ,
271272 https_proxy_string : str | None = None ,
@@ -277,6 +278,7 @@ def __init__(self, url: str='https://www.circl.lu/pdns/query',
277278 :param url: The URL of the service
278279 :param basic_auth: HTTP basic auth to cnnect to the service: ("username", "password")
279280 :param auth_token: HTTP basic auth but the token
281+ :param auth_header: HTTP header to use for authentication: ("X-API-AUTH", "1234")
280282 :param enable_cache: Cache responses locally
281283 :param cache_file: The file to cache the responses to
282284 :param https_proxy_string: The HTTP proxy to connect to the service (deprecated, use proxies instead)
@@ -303,6 +305,8 @@ def __init__(self, url: str='https://www.circl.lu/pdns/query',
303305 self .session .auth = basic_auth
304306 elif auth_token is not None :
305307 self .session .headers .update ({'Authorization' : auth_token })
308+ elif auth_header is not None :
309+ self .session .headers .update ({auth_header [0 ]: auth_header [1 ]})
306310 else :
307311 # No authentication defined.
308312 pass
0 commit comments