Skip to content

How to configure Typhoeus

William Entriken edited this page May 10, 2017 · 5 revisions

Typhoeus is responsible for the HTTP connection. We can configure much of html-proofers' behavior by configuring Typhoeus. For all of these configurations you will need to call html-proofer from Ruby and you cannot do this using the command-line version of the program.

Read Typhoeus documentation here.

Simple html-proofer ruby example:

TODO MAKE THIS A REAL RUBY FILE

# Normal way to run
HTML::Proofer.new("out/").run

# How to run with Typhoeus changes
typhoeus_configuration = { 
  :timeout => 10,
  :verbose => true 
}
HTML::Proofer.new("out/", {:typhoeus => typhoeus_configuration}).run

TODO: Explain how someone who never used ruby before can get this to run.

Add request timeouts

This will log timeout failures and stop the connection attempt if no connection is made within 10 seconds.

typhoeus_configuration = { 
  :timeout => 10,
  :verbose => true 
}

Support HTTP authentication

:domain_auth => { "github.com" => {
  :type => :header,
  :template => "Bearer %token%",
  :values => {
    :token => ENV['MACHINE_USER_TOKEN']
  }
} }
:domain_auth => { "oldsite.com" => {
  :type => :basic,
  :values => {
    :username => ENV['MACHINE_USERNAME'],
    :password => ENV['MACHINE_PASSWORD']
  }
} }