Skip to content

Commit

Permalink
Fail the connection on an unexpected continuation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed Jul 2, 2011
1 parent 7b68769 commit 06963c1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/em-imap/continuation_synchronisation.rb
Expand Up @@ -59,8 +59,12 @@ def await_continuations(&block)
# continuation responses onto the currently awaiting block.
def listen_for_continuation
add_response_handler do |response|
if awaiting_continuation? && response.is_a?(Net::IMAP::ContinuationRequest)
@awaiting_continuation.receive_event response
if response.is_a?(Net::IMAP::ContinuationRequest)
if awaiting_continuation?
@awaiting_continuation.receive_event response
else
fail_all Net::IMAP::ResponseError.new("Unexpected continuation response from server")
end
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions spec/continuation_synchronisation_spec.rb
Expand Up @@ -85,4 +85,9 @@
@connection.receive_response response2
a.should == [response1]
end

it "should fail the connection when an unexpected continuation response is received" do
@connection.should_receive(:fail_all).with(an_instance_of(Net::IMAP::ResponseError))
@connection.receive_response Net::IMAP::ContinuationRequest.new("hehe")
end
end

0 comments on commit 06963c1

Please sign in to comment.