-
Notifications
You must be signed in to change notification settings - Fork 577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accept a wider range of content types for DoH API calls. #3046
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. We'd need a changeset before we can merge !
@@ -54,7 +54,7 @@ function dohResolveTxtFactory({ | |||
? await response.text() | |||
: `Failed to resolve ${hostname}` | |||
throw new TypeError(message) | |||
} else if (contentType !== 'application/dns-json') { | |||
} else if (contentType?.match(/application\/(dns-)json/i) == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to make the (dns-)
part optional ? Or is there no particular meaning behind the parenthesis there ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh god, it definetly must be optional (that's half the point of my PR), sorry about that. I fixed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can land as is. Left a small question but nothing blobking.
Currently, the DoH calls fail when using google's DoH API, since it returns "application/json; charset=UTF-8" as its response's content-type and the code expects "application/dns-json" (which seems to be particular to Cloudflare).
Notice that Alibaba Cloud's DoH returns "application/json", for example.
While there is no agreed upon MIME type for DoH's JSON Schema, it seems judicious to have the doh handle resolver to accept at least the major existing APIs out of the box.