lib/httpx/request.rb in httpx-0.16.1 vs lib/httpx/request.rb in httpx-0.17.0
- old
+ new
@@ -39,20 +39,19 @@
# Exception raised during enumerable body writes
attr_reader :drain_error
def_delegator :@body, :empty?
- def_delegator :@body, :chunk!
-
def initialize(verb, uri, options = {})
@verb = verb.to_s.downcase.to_sym
@options = Options.new(options)
@uri = Utils.to_uri(uri)
if @uri.relative?
- raise(Error, "invalid URI: #{@uri}") unless @options.origin
+ origin = @options.origin
+ raise(Error, "invalid URI: #{@uri}") unless origin
- @uri = @options.origin.merge(@uri)
+ @uri = origin.merge(@uri)
end
raise(Error, "unknown method: #{verb}") unless METHODS.include?(@verb)
@headers = @options.headers_class.new(@options.headers)
@@ -96,11 +95,11 @@
end
def response=(response)
return unless response
- if response.status == 100
+ if response.is_a?(Response) && response.status == 100
@informational_status = response.status
return
end
@response = response
end
@@ -156,11 +155,11 @@
end
# :nocov:
class Body < SimpleDelegator
class << self
- def new(*, options)
+ def new(_, options)
return options.body if options.body.is_a?(self)
super
end
end
@@ -221,10 +220,10 @@
end
def unbounded_body?
return @unbounded_body if defined?(@unbounded_body)
- @unbounded_body = (chunked? || @body.bytesize == Float::INFINITY)
+ @unbounded_body = !@body.nil? && (chunked? || @body.bytesize == Float::INFINITY)
end
def chunked?
@headers["transfer-encoding"] == "chunked"
end