getdns
getdns copied to clipboard
Consider adding an error response dict
We should probably return a negative response dictionary for errors. It would be nice if the callback received at least the name being queried. (#108 from private repo)
At least for timeouts this is now actually specified:
quoting from 1.5:
The following are the values for callback_type.
GETDNS_CALLBACK_COMPLETE
The response has the requested data in it
GETDNS_CALLBACK_CANCEL
The calling program cancelled the callback; response is NULL
GETDNS_CALLBACK_TIMEOUT
The requested action timed out; response is filled in with empty structures
GETDNS_CALLBACK_ERROR
The requested action had an error; response is NULL
Willem: that's an incorrect reading of the spec. A negative response should get GETDNS_CALLBACK_COMPLETE. It is not an error, it is a response.
Changed title to more clearly convey the intent here. The suggested response dict is not for NXDOMAIN's but to provide more detailed error reporting. If we return a response with empty structures with GETDNS_CALLBACK_CANCEL and GETDNS_CALLBACK_ERROR, like we do with GETDNS_CALLBACK_TIMEOUT, then more detailed error reporting can be embedded therein.
We should note that this changes the fact that the user can currently ignore the response dict (and is not responsible for freeing it). So this is actually a major API change.
I fully agree with Sara about this being a major API change.