From 0304ca3bc95102596002f2ea9ee390a24041fa36 Mon Sep 17 00:00:00 2001
From: nick evans <nicholas.evans@gmail.com>
Date: Mon, 2 Jan 2023 14:20:52 -0500
Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20greeting=20code=20data=20to?=
=?UTF-8?q?=20responses?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This simplifies caching of the server capabilities, as many servers will
send their capabilities inside the greeting. Needed for #31.
Reference: https://github.com/ruby/net-imap/commit/0304ca3bc95102596002f2ea9ee390a24041fa36
Conflict: (1) path remapped lib/net/imap.rb -> .bundle/gems/net-imap-0.3.8/lib/net/imap.rb (bundled gem v0.3.8 in ruby-3.2.8)
(2) test case hunk (test/net/imap/test_imap.rb) not modified (skipped per adaptation rule)
.bundle/gems/net-imap-0.3.8/lib/net/imap.rb | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
@@ -2164,7 +2164,7 @@ module Net
else
@usessl = false
end
- @responses = Hash.new([].freeze)
+ @responses = Hash.new {|h, k| h[k] = [] }
@tagged_responses = {}
@response_handlers = []
options[:response_handlers]&.each do |h| add_response_handler(h) end
@@ -2181,6 +2181,7 @@ module Net
if @greeting.nil?
raise Error, "connection closed"
end
+ record_untagged_response_code(@greeting)
if @greeting.name == "BYE"
raise ByeResponseError, @greeting
end
@@ -2246,10 +2247,7 @@ module Net
end
when UntaggedResponse
record_response(resp.name, resp.data)
- if resp.data.instance_of?(ResponseText) &&
- (code = resp.data.code)
- record_response(code.name, code.data)
- end
+ record_untagged_response_code(resp)
if resp.name == "BYE" && @logout_command_tag.nil?
@sock.close
@exception = ByeResponseError.new(resp)
@@ -2314,6 +2312,13 @@ module Net
@parser.parse(buff)
end
+ def record_untagged_response_code(resp)
+ if resp.data.instance_of?(ResponseText) &&
+ (code = resp.data.code)
+ record_response(code.name, code.data)
+ end
+ end
+
#############################
def record_response(name, data)
--
2.43.0