Skip to content

Instantly share code, notes, and snippets.

@picatz
Created April 3, 2018 14:30
Show Gist options
  • Save picatz/c665fc5fe9b642babfc334ee3ac4ba61 to your computer and use it in GitHub Desktop.
Save picatz/c665fc5fe9b642babfc334ee3ac4ba61 to your computer and use it in GitHub Desktop.
Cloudflare DNS over HTTPs Example
require 'httparty'
url = "https://cloudflare-dns.com/dns-query"
query = { name: "microsoft.com", type: "MX", ct: "application/dns-json" }
headers = {'Content-Type': 'application/json'}
buffer = StringIO.new
response = HTTParty.get(url, stream_body: true, query: query, headers: headers) do |fragment|
buffer << fragment
end
if response.success?
puts buffer.string
else
puts "Failed to get successful response!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment