Class: Dialed::HTTP::Response::Body

Inherits:
Object
  • Object
show all
Defined in:
lib/dialed/http/response/body.rb

Direct Known Subclasses

EveryBody, JsonBody

Instance Method Summary collapse

Constructor Details

#initialize(internal_body) ⇒ Body

Returns a new instance of Body.



6
7
8
9
# File 'lib/dialed/http/response/body.rb', line 6

def initialize(internal_body)
  @internal_body = internal_body
  @file = nil
end

Instance Method Details

#http2?Boolean

Returns:

  • (Boolean)


32
# File 'lib/dialed/http/response/body.rb', line 32

def http2?; end

#readObject

Raises:

  • (NotImplementedError)


11
12
13
# File 'lib/dialed/http/response/body.rb', line 11

def read
  raise NotImplementedError
end

#to_ioObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/dialed/http/response/body.rb', line 15

def to_io
  @to_io ||= begin
               file = nil
               begin
                 file = ::Tempfile.create(anonymous: true)
                 internal_body.each do |chunk|
                   file.write(chunk)
                 end
                 file.rewind
                 file
               rescue => e
                 file.close
                 raise e
               end
             end
end