Created
April 3, 2018 14:30
-
-
Save picatz/c665fc5fe9b642babfc334ee3ac4ba61 to your computer and use it in GitHub Desktop.
Cloudflare DNS over HTTPs Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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