Class: Capybara::Mechanize::Browser
- Inherits:
-
Object
- Object
- Capybara::Mechanize::Browser
- Defined in:
- lib/monkey-patches/capybara-mechanize-patches.rb
Instance Method Summary collapse
-
#process_remote_request(method, url, attributes, headers) ⇒ Object
patch to remove catching all Mechanize exceptions (which are nice and specific) and throwing a useless RuntimeError patch to add Referer ([email protected] won’t add Referer for urls starting with http(s)://.).
Instance Method Details
#process_remote_request(method, url, attributes, headers) ⇒ Object
patch to remove catching all Mechanize exceptions (which are nice and specific) and throwing a useless RuntimeError patch to add Referer ([email protected] won’t add Referer for urls starting with http(s)://.)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/monkey-patches/capybara-mechanize-patches.rb', line 6 def process_remote_request(method, url, attributes, headers) if remote?(url) uri = URI.parse(url) uri = resolve_relative_url(url) if uri.host.nil? @last_remote_uri = uri url = uri.to_s referer = nil referer_candidate = current_url unless referer_candidate.empty? or (referer_candidate.start_with?('https://') and url.start_with?('http://')) referer = referer_candidate end reset_cache! args = [] args << attributes unless attributes.empty? args << headers unless headers.empty? if method == :get agent.send(method, url, attributes, referer, headers) else agent.send(method, url, *args) end @last_request_remote = true end end |