Option to remove non permanent headers on redirects #857
Glad you asked, I waited for the question.
In one of our Rails apps we have a splitted HTTP/HTTPS routing, the pages are only available via one protocol, not both. Poltergeist/Capybara provides no distinct HTTPS server, so every visit has to go to the standard HTTP server. An HTTP header
So we provide two helper methods for our feature specs to annotate which clicks will result in HTTPS requests. Code says more than thousand words:
module SslAnnotation def next_page_has_ssl_url page.driver.add_header('X-Forwarded-SSL', 'on', permanent: false) end def next_page_has_ssl_url_but_redirects_to_nonssl_url page.driver.add_header('X-Forwarded-SSL', 'on', permanent: false, for_followed_redirect: false) end RSpec.configuration.include(SslAnnotation)
If you request the target URL (HTTPS) and it redirects to a HTTP URL, Poltergeist requests this URL also with the configured header. This needs to get disabled with the
Ok -- so if we're going to go with this, the options are a problem since a user could specify-