lib/httpx/plugins/proxy.rb in httpx-0.7.0 vs lib/httpx/plugins/proxy.rb in httpx-0.8.0
- old
+ new
@@ -177,24 +177,13 @@
return super unless @options.proxy
super || @state == :connecting || @state == :connected
end
- def to_io
- return super unless @options.proxy
-
- case @state
- when :idle
- transition(:connecting)
- when :connected
- transition(:open)
- end
- @io.to_io
- end
-
def call
super
+
return unless @options.proxy
case @state
when :connecting
consume
@@ -208,14 +197,29 @@
transition(:closing)
transition(:closed)
emit(:close)
end
+ private
+
+ def connect
+ return super unless @options.proxy
+
+ case @state
+ when :idle
+ transition(:connecting)
+ when :connected
+ transition(:open)
+ end
+ end
+
def transition(nextstate)
return super unless @options.proxy
case nextstate
when :closing
+ # this is a hack so that we can use the super method
+ # and it'll thing that the current state is open
@state = :open if @state == :connecting
end
super
end
end