Skip to content

Commit

Permalink
To fix a bug that causes retry fail.
Browse files Browse the repository at this point in the history
Often we get 500 internal server error from S3 and HTTPConnection will retry with a file pointer pointing to EOF, which leads to 400 Bad Request -- "RequestTimeout"

git-svn-id: https://wush.net/svn/rightscale/right_http_connection/trunk@3889 9f0cbaf6-ce18-0410-ad37-d14a22affa91
  • Loading branch information
David Chia committed May 15, 2008
1 parent 1ce826a commit 8a52691
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/right_http_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ def request(request_params, &block)
request.content_length = body.respond_to?(:lstat) ? body.lstat.size : body.size
request.body_stream = request.body
end

# Always make sure that the file pointer is set to point to the beginning of the file
request.body.seek(0,IO::SEEK_SET) if request.body
request.body_stream.seek(0,IO::SEEK_SET) if request.body_stream

response = @http.request(request, &block)

error_reset
Expand Down

0 comments on commit 8a52691

Please sign in to comment.