Permalink
Browse files

Change HTTP API requests to use POST instead of GET.

Based on patch #18380 from 'anonymous'.

The library currently uses a GET request on the query API. If you
are sending a lot if user data this pushes the GET URL past what
Amazon accepts.

I've made changes to make use of a POST instead to work
around this limitation. You can pull my changes from

http://inodes.org/~johnf/git/amazon-ec2
  • Loading branch information...
1 parent 53ae17b commit 1f1a53d025837f32ff5a11d240130ac631b08fdb @grempe committed Feb 26, 2008
Showing with 11 additions and 14 deletions.
  1. +3 −0 History.txt
  2. +6 −12 lib/EC2.rb
  3. +1 −1 lib/EC2/version.rb
  4. +1 −1 test/test_EC2_version.rb
View
3 History.txt
@@ -1,3 +1,6 @@
+=== 0.2.8 2008-02-25
+ * Change HTTP API requests to use POST instead of GET. Based on patch #18380 from 'anonymous'.
+
=== 0.2.7 2008-02-17
* Add support for HTTP Proxy when :proxy_server argument is passed. Based on patch from Mathias Dalheimer.
View
18 lib/EC2.rb
@@ -164,25 +164,19 @@ def make_request(action, params, data='')
"Version" => API_VERSION,
"Timestamp"=>Time.now.getutc.iso8601} )
- sigpath = "?" + params.sort_by { |param| param[0].downcase }.collect { |param| param.join("=") }.join("&")
+ sigquery = params.sort_by { |param| param[0].downcase }.collect { |param| param.join("=") }.join("&")
- sig = get_aws_auth_param(sigpath, @secret_access_key)
+ sig = get_aws_auth_param(sigquery, @secret_access_key)
- path = "?" + params.sort.collect do |param|
+ query = params.sort.collect do |param|
CGI::escape(param[0]) + "=" + CGI::escape(param[1])
end.join("&") + "&Signature=" + sig
- req = Net::HTTP::Get.new("/#{path}")
-
- # Ruby will automatically add a random content-type on some verbs, so
- # here we add a dummy one to 'supress' it. Change this logic if having
- # an empty content-type header becomes semantically meaningful for any
- # other verb.
- req['Content-Type'] ||= ''
+ req = Net::HTTP::Post.new("/")
+ req.content_type = 'application/x-www-form-urlencoded'
req['User-Agent'] = "rubyforge-amazon-ec2-ruby-gem-query-api v-#{RELEASE_VERSION}"
- #data = nil unless req.request_body_permitted?
- response = @http.request(req, nil)
+ response = @http.request(req, query)
# Make a call to see if we need to throw an error based on the response given by EC2
# All error classes are defined in EC2/exceptions.rb
View
2 lib/EC2/version.rb
@@ -12,7 +12,7 @@ module EC2 #:nodoc:
module VERSION #:nodoc:
MAJOR = 0
MINOR = 2
- TINY = 7
+ TINY = 8
STRING = [MAJOR, MINOR, TINY].join('.')
end
end
View
2 test/test_EC2_version.rb
@@ -16,7 +16,7 @@
setup do
@major = 0
@minor = 2
- @tiny = 7
+ @tiny = 8
@string = [@major, @minor, @tiny].join('.')
end

0 comments on commit 1f1a53d

Please sign in to comment.