Public Class methods
new(body)
[show source]
# File lib/httpx/transcoder/body.rb 12 def initialize(body) 13 body = body.open(File::RDONLY, encoding: Encoding::BINARY) if Object.const_defined?(:Pathname) && body.is_a?(Pathname) 14 @body = body 15 super(body) 16 end
Public Instance methods
bytesize()
[show source]
# File lib/httpx/transcoder/body.rb 18 def bytesize 19 if @body.respond_to?(:bytesize) 20 @body.bytesize 21 elsif @body.respond_to?(:to_ary) 22 @body.sum(&:bytesize) 23 elsif @body.respond_to?(:size) 24 @body.size || Float::INFINITY 25 elsif @body.respond_to?(:length) 26 @body.length || Float::INFINITY 27 elsif @body.respond_to?(:each) 28 Float::INFINITY 29 else 30 raise Error, "cannot determine size of body: #{@body.inspect}" 31 end 32 end
content_type()
[show source]
# File lib/httpx/transcoder/body.rb 34 def content_type 35 "application/octet-stream" 36 end