[英]DNS query not specified or too small
I'm trying to make a python script to test if a server can answer in DNS-over-HTTPS .我正在尝试制作一个 python 脚本来测试服务器是否可以在DNS-over-HTTPS中回答。 So, I read this article and try to make the same request but in python:
因此,我阅读了这篇文章并尝试在 python 中提出相同的请求:
import requests
r=requests.get("https://cloudflare-dns.com/dns-query?name=example.com&type=A", headers={"accept":"application/dns-message"})
print(r.url)
print(r.headers)
print(r.status_code)
Here is the output这是输出
https://cloudflare-dns.com/dns-query?name=example.com&type=A
https://cloudflare-dns.com/dns-query?name=example.com&type=A
{'Access-Control-Allow-Origin': '*', 'Vary': 'Accept-Encoding', 'CF-RAY': '48b33f92aec83e4a-ZRH', 'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Date': 'Tue, 18 Dec 2018 17:11:23 GMT', 'Transfer-Encoding': 'chunked', 'Server': 'cloudflare', 'Connection': 'keep-alive'} 400
{'Access-Control-Allow-Origin': '*', 'Vary': 'Accept-Encoding', 'CF-RAY': '48b33f92aec83e4a-ZRH', 'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', '日期': '星期二, 2018 年 12 月 18 日 17:11:23 GMT', 'Transfer-编码':'分块','服务器':'cloudflare','连接':'保持活动'} 400
If I base me on what's written here , my request is not specified or too small .如果我基于此处所写的内容,则我的要求未指定或太小。
Does anyone sees where I'm mistaking?有没有人看到我在哪里弄错了?
Thanks谢谢
The form you are using to pass parameters needs application/dns-json
as MIME Accept type.您用来传递参数的表单需要
application/dns-json
作为 MIME Accept 类型。 Otherwise for application/dns-message
you have only a dns
key with the value being the full DNS message encoded.否则,对于
application/dns-message
,您只有一个dns
密钥,其值为完整的 DNS 消息编码。
Compare:比较:
curl -H 'accept: application/dns-json' 'https://cloudflare-dns.com/dns-query?name=example.com&type=AAAA'
(from https://developers.cloudflare.com/1.1.1.1/dns-over-https/json-format/ ) (来自https://developers.cloudflare.com/1.1.1.1/dns-over-https/json-format/ )
with和
curl -H 'accept: application/dns-message' -v 'https://cloudflare-dns.com/dns-query?dns=q80BAAABAAAAAAAAA3d3dwdleGFtcGxlA2NvbQAAAQAB' | hexdump
(from https://developers.cloudflare.com/1.1.1.1/dns-over-https/wireformat/ ) (来自https://developers.cloudflare.com/1.1.1.1/dns-over-https/wireformat/ )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.