lib/httpx/request.rb in httpx-0.10.2 vs lib/httpx/request.rb in httpx-0.11.0
- old
+ new
@@ -79,10 +79,14 @@
end
def response=(response)
return unless response
+ if response.status == 100
+ @informational_status = response.status
+ return
+ end
@response = response
end
def path
path = uri.path.dup
@@ -168,10 +172,16 @@
else
block[body.to_s]
end
end
+ def rewind
+ return if empty?
+
+ @body.rewind if @body.respond_to?(:rewind)
+ end
+
def empty?
return true if @body.nil?
return false if chunked?
@body.bytesize.zero?
@@ -210,28 +220,29 @@
end
def transition(nextstate)
case nextstate
when :idle
+ @body.rewind
@response = nil
@drainer = nil
when :headers
return unless @state == :idle
when :body
return unless @state == :headers ||
@state == :expect
if @headers.key?("expect")
- unless @response
- @state = :expect
- return
- end
+ if @informational_status && @informational_status == 100
+ # check for 100 Continue response, and deallocate the var
+ # if @informational_status == 100
+ # @response = nil
+ # end
+ else
+ return if @state == :expect # do not re-set it
- case @response.status
- when 100
- # deallocate
- @response = nil
+ nextstate = :expect
end
end
when :done
return if @state == :expect
end
@@ -239,11 +250,10 @@
emit(@state)
nil
end
def expects?
- @headers["expect"] == "100-continue" &&
- @response && @response.status == 100
+ @headers["expect"] == "100-continue" && @informational_status == 100 && !@response
end
class ProcIO
def initialize(block)
@block = block