Skip to content

Commit

Permalink
Merge pull request #58 from pogzyb/handle-empty-queries
Browse files Browse the repository at this point in the history
Add check for empty query_output
  • Loading branch information
pogzyb authored Jun 2, 2023
2 parents ab1fb1f + a1803a8 commit bfbf43e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions asyncwhois/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,13 @@ def _do_query(self, server: str, data: str, regex: str) -> str:
whois_server = whois_server.lower()
if whois_server and whois_server != server:
# recursive call to find more authoritative server
query_output = self._do_query(
authoritative_output = self._do_query(
whois_server, data, self.whois_server_regex
)
# check for empty responses; only update query_output if
# there was a complete response from the authoritative server
if authoritative_output:
query_output = authoritative_output
# return the WHOIS query output
return query_output

Expand All @@ -167,9 +171,13 @@ async def _aio_do_query(self, server: str, data: str, regex: str):
whois_server = whois_server.lower()
if whois_server and whois_server != server:
# recursive call to find the authoritative server
query_output = await self._aio_do_query(
authoritative_output = await self._aio_do_query(
whois_server, data, self.whois_server_regex
)
# check for empty responses; only update query_output if
# there was a complete response from the authoritative server
if authoritative_output:
query_output = authoritative_output
# return the WHOIS query output
return query_output

Expand Down

0 comments on commit bfbf43e

Please sign in to comment.