File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1047,6 +1047,7 @@ def connect
10471047 write_timeout : @write_timeout ,
10481048 continue_timeout : @continue_timeout ,
10491049 debug_output : @debug_output )
1050+ @last_communicated = nil
10501051 on_connect
10511052 rescue => exception
10521053 if s
Original file line number Diff line number Diff line change @@ -1168,6 +1168,30 @@ def test_keep_alive_get_auto_retry
11681168 }
11691169 end
11701170
1171+ def test_keep_alive_reset_on_new_connection
1172+ # Using WEBrick's debug log output on accepting connection:
1173+ #
1174+ # "[2021-04-29 20:36:46] DEBUG accept: 127.0.0.1:50674\n"
1175+ @log_tester = nil
1176+ @server . logger . level = WEBrick ::BasicLog ::DEBUG
1177+
1178+ start { |http |
1179+ res = http . get ( '/' )
1180+ http . keep_alive_timeout = 1
1181+ assert_kind_of Net ::HTTPResponse , res
1182+ assert_kind_of String , res . body
1183+ http . finish
1184+ assert_equal 1 , @log . grep ( /accept/i ) . size
1185+
1186+ sleep 1.5
1187+ http . start
1188+ res = http . get ( '/' )
1189+ assert_kind_of Net ::HTTPResponse , res
1190+ assert_kind_of String , res . body
1191+ assert_equal 2 , @log . grep ( /accept/i ) . size
1192+ }
1193+ end
1194+
11711195 class MockSocket
11721196 attr_reader :count
11731197 def initialize ( success_after : nil )
You can’t perform that action at this time.
0 commit comments