setup to send body data

This commit is contained in:
Wesley Beary 2009-06-07 01:11:13 -07:00
parent 9ffd798b5e
commit c2a6e8b829
1 changed files with 6 additions and 2 deletions

View File

@ -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)