From 2ee9b5ae4726e82246f8e79afb071c06e98a35f9 Mon Sep 17 00:00:00 2001 From: Matt Byrne Date: Mon, 25 Jul 2016 15:31:32 +0100 Subject: [PATCH] Overloaded Client to accept trustAllServers parameter --- lib/browsermob/proxy/client.rb | 4 ++-- lib/browsermob/proxy/server.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/browsermob/proxy/client.rb b/lib/browsermob/proxy/client.rb index 160880a..9442e7f 100644 --- a/lib/browsermob/proxy/client.rb +++ b/lib/browsermob/proxy/client.rb @@ -4,12 +4,12 @@ module Proxy class Client attr_reader :host, :port - def self.from(server_url, port = nil) + def self.from(server_url, port = nil, trust_all_servers = false) # ActiveSupport may define Object#load, so we can't use MultiJson.respond_to? here. sm = MultiJson.singleton_methods.map { |e| e.to_sym } decode_method = sm.include?(:load) ? :load : :decode - new_proxy_url = URI.join(server_url, "proxy") + new_proxy_url = URI.join(server_url, "proxy", "?trustAllServers=#{trust_all_servers}") new_proxy_url.query = "port=#{port}" if port port = MultiJson.send(decode_method, diff --git a/lib/browsermob/proxy/server.rb b/lib/browsermob/proxy/server.rb index 84e18e4..39301a2 100644 --- a/lib/browsermob/proxy/server.rb +++ b/lib/browsermob/proxy/server.rb @@ -43,8 +43,8 @@ def url "http://localhost:#{port}" end - def create_proxy(port = nil) - Client.from url, port + def create_proxy(port = nil, trust_all_servers = false) + Client.from url, port, trust_all_servers end def stop