lib/httpx/request.rb in httpx-0.15.4 vs lib/httpx/request.rb in httpx-0.16.0

- old
+ new

@@ -1,7 +1,8 @@ # frozen_string_literal: true +require "delegate" require "forwardable" module HTTPX class Request extend Forwardable @@ -153,11 +154,11 @@ "@headers=#{@headers} " \ "@body=#{@body}>" end # :nocov: - class Body + class Body < SimpleDelegator class << self def new(*, options) return options.body if options.body.is_a?(self) super @@ -175,10 +176,11 @@ end return if @body.nil? @headers["content-type"] ||= @body.content_type @headers["content-length"] = @body.bytesize unless unbounded_body? + super(@body) end def each(&block) return enum_for(__method__) unless block_given? return if @body.nil? @@ -212,11 +214,11 @@ @body.bytesize end def stream(body) encoded = body - encoded = Transcoder.registry("chunker").encode(body) if chunked? + encoded = Transcoder.registry("chunker").encode(body.enum_for(:each)) if chunked? encoded end def unbounded_body? return @unbounded_body if defined?(@unbounded_body) @@ -236,19 +238,9 @@ def inspect "#<HTTPX::Request::Body:#{object_id} " \ "#{unbounded_body? ? "stream" : "@bytesize=#{bytesize}"}>" end # :nocov: - - def respond_to_missing?(meth, *args) - @body.respond_to?(meth, *args) || super - end - - def method_missing(meth, *args, &block) - return super unless @body.respond_to?(meth) - - @body.__send__(meth, *args, &block) - end end def transition(nextstate) case nextstate when :idle