Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reconnect with HTTPS fix: establish SSL connection also when reconnecting #25

Merged
merged 1 commit into from
Apr 10, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/twitter/json_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def self.connect options = {}
end

connection = EventMachine.connect host, port, self, options
connection.start_tls if options[:ssl]
connection
end

Expand Down Expand Up @@ -122,6 +121,7 @@ def receive_data(data)
end

def connection_completed
start_tls if @options[:ssl]
send_request
end

Expand Down
13 changes: 13 additions & 0 deletions spec/twitter/json_stream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ def receive_data data
stream = JSONStream.connect(:proxy => "http://my-proxy:8080") {}
end

it "should not trigger SSL until connection is established" do
connection = stub('connection')
EM.should_receive(:connect).and_return(connection)
stream = JSONStream.connect(:ssl => true)
stream.should == connection
end

end

context "on valid stream" do
Expand Down Expand Up @@ -198,6 +205,12 @@ def receive_data data
end
end

it "should reconnect with SSL if enabled" do
connect_stream :ssl => true do
stream.should_receive(:start_tls).twice
end
end

it_should_behave_like "network failure"
end

Expand Down