From c2a6e8b8298af1c875dab4ca15fabdc6462b0413 Mon Sep 17 00:00:00 2001 From: Wesley Beary Date: Sun, 7 Jun 2009 01:11:13 -0700 Subject: [PATCH] setup to send body data --- lib/fog/aws.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/fog/aws.rb b/lib/fog/aws.rb index e3a615069..a032dea48 100644 --- a/lib/fog/aws.rb +++ b/lib/fog/aws.rb @@ -10,10 +10,11 @@ module Fog class Connection < EventMachine::Connection include EventMachine::Deferrable - attr_accessor :headers, :method, :parser, :url + attr_accessor :body, :headers, :method, :parser, :url attr_reader :response def post_init + @body ||= nil @data ||= nil @headers ||= {} @method ||= 'GET' @@ -32,7 +33,10 @@ module Fog path = "#{uri.path}#{uri.query.nil? ? "" : "?#{uri.query}"}" host = "#{uri.host}#{uri.port == 80 ? "" : ":#{uri.port}"}" @headers.merge!({'Host' => host}) - send_data("#{method} #{path} HTTP/1.1\r\n#{headers.collect {|k,v| "#{k}: #{v}\r\n"}.join('')}\r\n") + request = "#{method} #{path} HTTP/1.1\r\n" + request << "#{headers.collect {|k,v| "#{k}: #{v}\r\n"}.join('')}\r\n" + request << "\r\n#{@body}\r\n" if @body + send_data(request) end def receive_data(data)