Skip to content

Commit

Permalink
Clean up proxy interface
Browse files Browse the repository at this point in the history
  • Loading branch information
halogenandtoast committed Oct 14, 2011
1 parent 229a20e commit 93bfcf6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
24 changes: 15 additions & 9 deletions lib/capybara/driver/webkit/browser.rb
Expand Up @@ -99,16 +99,13 @@ def get_cookies
command("GetCookies").lines.map{ |line| line.strip }.select{ |line| !line.empty? }
end

def set_proxy(opts = {})
# remove proxy?
return command("SetProxy") if opts.empty?
def set_proxy(options = {})
options = default_proxy_options.merge(options)
command("SetProxy", options[:host], options[:port], options[:user], options[:pass])
end

# set a HTTP proxy
command("SetProxy",
opts[:host] || "localhost",
opts[:port] || "0",
opts[:user] || "",
opts[:pass] || "")
def clear_proxy
command("SetProxy")
end

private
Expand Down Expand Up @@ -206,5 +203,14 @@ def read_response
response.force_encoding("UTF-8") if response.respond_to?(:force_encoding)
response
end

def default_proxy_options
{
:host => "localhost",
:port => "0",
:user => "",
:pass => ""
}
end
end
end
2 changes: 1 addition & 1 deletion spec/browser_spec.rb
Expand Up @@ -170,7 +170,7 @@

it 'is possible to disable proxy again' do
@proxy_requests.clear
browser.set_proxy
browser.clear_proxy
browser.visit "http://#{@host}:#{@port}/"
@proxy_requests.size.should == 0
end
Expand Down
1 change: 1 addition & 0 deletions src/CommandFactory.cpp
Expand Up @@ -17,6 +17,7 @@
#include "SetCookie.h"
#include "ClearCookies.h"
#include "GetCookies.h"
#include "SetProxy.h"

CommandFactory::CommandFactory(WebPage *page, QObject *parent) : QObject(parent) {
m_page = page;
Expand Down

0 comments on commit 93bfcf6

Please sign in to comment.