Skip to content

Commit 5e81dc4

Browse files
committed
fix: Ensure rack is available, and handle nil HTTP response
1 parent 84c895e commit 5e81dc4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/appmap/handler/net_http.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'appmap/event'
44
require 'appmap/util'
5+
require 'rack'
56

67
module AppMap
78
module Handler
@@ -60,10 +61,14 @@ class HTTPClientResponse < AppMap::Event::MethodReturnIgnoreValue
6061
def initialize(response, parent_id, elapsed)
6162
super AppMap::Event.next_id_counter, :return, Thread.current.object_id
6263

63-
self.status = response.code.to_i
64+
if response
65+
self.status = response.code.to_i
66+
self.headers = NetHTTP.copy_headers(response)
67+
else
68+
self.headers = {}
69+
end
6470
self.parent_id = parent_id
6571
self.elapsed = elapsed
66-
self.headers = NetHTTP.copy_headers(response)
6772
end
6873

6974
def to_h

0 commit comments

Comments
 (0)