lib/httpx/plugins/proxy/socks4.rb in httpx-0.0.5 vs lib/httpx/plugins/proxy/socks4.rb in httpx-0.1.0

- old
+ new

@@ -28,15 +28,11 @@ request_uri = req.uri @io = ProxySSL.new(@io, request_uri, @options) if request_uri.scheme == "https" transition(:connected) throw(:called) else - response = ErrorResponse.new(Error.new("socks error: #{status}"), 0, @options) - until @pending.empty? - req, _ = @pending.shift - emit(:response, req, response) - end + on_socks_error("socks error: #{status}") end end def transition(nextstate) case nextstate @@ -51,11 +47,18 @@ proxy_connect when :connected return unless @state == :connecting @parser = nil end - log(level: 1, label: "SOCKS4: ") { "#{nextstate}: #{@write_buffer.to_s.inspect}" } + log(level: 1, label: "SOCKS4: ") { "#{nextstate}: #{@write_buffer.to_s.inspect}" } unless nextstate == :open super + end + + def on_socks_error(message) + ex = Error.new(message) + ex.set_backtrace(caller) + on_error(ex) + throw(:called) end end Parameters.register("socks4", Socks4ProxyChannel) Parameters.register("socks4a", Socks4ProxyChannel)