class Helmet::DNSPrefetchControllerHandler

Overview

Some browsers optimistically prefetch DNS records for performance, which can have security implications. Read more about it on MDN and on Chromium's docs.

This handler sets the X-DNS-Prefetch-Control to control browsers' DNS prefetching behavior.

Disable DNS prefetching

You can disable DNS prefetching:

server = HTTP::Server.new("0.0.0.0", 8080, [
  Helmet::DNSPrefetchControllerHandler.new(allow: false),
  # ...
])

You can also leave out the allow argument if you're doing this—false is the default:

server = HTTP::Server.new("0.0.0.0", 8080, [
  Helmet::DNSPrefetchControllerHandler.new,
  # ...
])

Enable DNS prefetching

server = HTTP::Server.new("0.0.0.0", 8080, [
  Helmet::DNSPrefetchControllerHandler.new(allow: true),
  # ...
])

Defined in:

helmet/dnsprefetchcontrolhandler.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.new(allowed : Bool = false) #

[View source]

Instance Method Detail

def call(context : HTTP::Server::Context) #

[View source]