Skip to content

Commit

Permalink
Make the comment for retry_change_requests scarier
Browse files Browse the repository at this point in the history
Simplify #can_retry?

Update history
  • Loading branch information
drbrain committed Jun 27, 2011
1 parent c865a9f commit 779800b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
8 changes: 8 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
=== 1.8 / 2011-06-27

* Minor Enhancement
* Added Net::HTTP::Persistent#retry_change_requests which allows POST and
other non-idempotent requests to be retried automatically. Take care when
enabling this option to ensure the server will handle multiple POSTs with
the same data in a sane manner.

=== 1.7 / 2011-04-17

* Minor Enhancement
Expand Down
18 changes: 9 additions & 9 deletions lib/net/http/persistent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Net::HTTP::Persistent
##
# The version of Net::HTTP::Persistent use are using

VERSION = '1.7'
VERSION = '1.8'

##
# Error class for errors raised by Net::HTTP::Persistent. Various
Expand Down Expand Up @@ -153,9 +153,13 @@ class Error < StandardError; end
attr_accessor :verify_mode

##
# Enable retries of non-idempotent requests (e.g. POST requests) when the
# server has disconnected. This can in the worst case lead to multiple
# requests with the same data, but it is useful for simpler applications.
# Enable retries of non-idempotent requests that change data (e.g. POST
# requests) when the server has disconnected.
#
# This will in the worst case lead to multiple requests with the same data,
# but it may be useful for some applications. Take care when enabling
# this option to ensure it is safe to POST or perform other non-idempotent
# requests to the server.

attr_accessor :retry_change_requests

Expand Down Expand Up @@ -318,11 +322,7 @@ def idempotent? req
# Is the request idempotent or is retry_change_requests allowed

def can_retry? req
if idempotent? req
true
else
retry_change_requests
end
retry_change_requests or idempotent?(req)
end

##
Expand Down

0 comments on commit 779800b

Please sign in to comment.