6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/postbox/http.rb', line 6
def post_item(item)
begin
item.response = post(item.url, :body => item.params)
item.success = (200..299) === item.response.code
return true
rescue Timeout::Error, Errno::ECONNREFUSED, SocketError => error
item.last_error = error
item.last_attempt_at = Time.now
item.post_attempts += 1
return false
rescue => error
item.success = false
item.last_error = error
return false
ensure
item.callback.call(item) unless item.callback.nil?
end
end
|