Skip to content
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

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

sgarciac
Copy link
Contributor

@sgarciac sgarciac commented Nov 19, 2024

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.

Copy link
Contributor

@matthieusieben matthieusieben left a 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) {
Copy link
Contributor

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 ?

Copy link
Contributor Author

@sgarciac sgarciac Dec 12, 2024

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.

Copy link
Contributor

@matthieusieben matthieusieben left a 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.

@matthieusieben matthieusieben merged commit a200e50 into bluesky-social:main Dec 17, 2024
10 checks passed
@github-actions github-actions bot mentioned this pull request Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants