86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# 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
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 || 'connection closed by server')
end
end
|