# File lib/em-http/client.rb, line 86 def unbind(reason = nil) if finished? if redirect? begin @conn.middleware.each do |m| m.response(self) if m.respond_to?(:response) end # one of the injected middlewares could have changed # our redirect settings, check if we still want to # follow the location header if redirect? @req.followed += 1 @cookies.clear @cookies = @cookiejar.get(@response_header.location).map(&:to_s) if @req.pass_cookies @req.set_uri(@response_header.location) @conn.redirect(self) else succeed(self) end rescue Exception => e on_error(e.message) end else succeed(self) end else on_error(reason) end end