Skip to content

Commit

Permalink
#125 - fixes redirect bug in file PUT requests
Browse files Browse the repository at this point in the history
(cherry picked from commit add2d75)
  • Loading branch information
caryp committed Mar 22, 2012
1 parent 740c54f commit f535e13
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/awsbase/right_awsbase.rb
Expand Up @@ -926,19 +926,21 @@ def check(request) #:nodoc:
sleep @reiteration_delay
@reiteration_delay *= 2

# Always make sure that the fp is set to point to the beginning(?)
# of the File/IO. TODO: it assumes that offset is 0, which is bad.
if(request[:request].body_stream && request[:request].body_stream.respond_to?(:pos))
begin
request[:request].body_stream.pos = 0
rescue Exception => e
@logger.warn("Retry may fail due to unable to reset the file pointer" +
" -- #{self.class.name} : #{e.inspect}")
end
end
else
@aws.logger.info("##### Retry ##{@retries} is being performed due to a redirect. ####")
end

# Always make sure that the fp is set to point to the beginning(?)
# of the File/IO. TODO: it assumes that offset is 0, which is bad.
if(request[:request].body_stream && request[:request].body_stream.respond_to?(:pos))
begin
request[:request].body_stream.pos = 0
rescue Exception => e
@logger.warn("Retry may fail due to unable to reset the file pointer" +
" -- #{self.class.name} : #{e.inspect}")
end
end

result = @aws.request_info(request, @parser)
else
@aws.logger.warn("##### Ooops, time is over... ####")
Expand Down

0 comments on commit f535e13

Please sign in to comment.