lib/httpx/plugins/grpc/call.rb in httpx-0.15.4 vs lib/httpx/plugins/grpc/call.rb in httpx-0.16.0

- old
+ new

@@ -8,10 +8,11 @@ attr_writer :decoder def initialize(response) @response = response @decoder = ->(z) { z } + @consumed = false end def inspect "#GRPC::Call(#{grpc_response})" end @@ -23,11 +24,11 @@ def metadata response.headers end def trailing_metadata - return unless @response.body.closed? + return unless @consumed @response.trailing_metadata end private @@ -38,11 +39,13 @@ @grpc_response = if @response.respond_to?(:each) Enumerator.new do |y| Message.stream(@response).each do |message| y << @decoder.call(message) end + @consumed = true end else + @consumed = true @decoder.call(Message.unary(@response)) end end def respond_to_missing?(meth, *args, &blk)