Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fail the connection on an unexpected continuation.

  • Loading branch information...
commit 06963c1d959d758809dd2304c8501c7ec901c197 1 parent 7b68769
@ConradIrwin ConradIrwin authored
View
8 lib/em-imap/continuation_synchronisation.rb
@@ -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
View
5 spec/continuation_synchronisation_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.