lib/sqs/right_sqs_interface.rb
# Generates a request hash for the REST API
Generates a request hash for the REST API
Generates a request hash for the REST API
def generate_rest_request(method, param) 
      queue_uri = param[:queue_url] ? URI(param[:queue_url]).path : '/'
      message   = param[:message]                
      param.each{ |key, value| param.delete(key) if (value.nil? || key.is_a?(Symbol)) }
      param_to_str = param.to_a.collect{|key,val| key.to_s + "=" + CGI::escape(val.to_s) }.join("&")
      param_to_str = "?#{param_to_str}" unless param_to_str.right_blank?
      request = "Net::HTTP::#{method.capitalize}".right_constantize.new("#{queue_uri}#{param_to_str}")
      request.body = message if message
      request['content-md5']  = ''
      request['Content-Type'] = 'text/plain'
      request['Date']         = Time.now.httpdate
      auth_string = "#{method.upcase}\n#{request['content-md5']}\n#{request['Content-Type']}\n#{request['Date']}\n#{CGI::unescape(queue_uri)}"
      signature   = AwsUtils::sign(@aws_secret_access_key, auth_string)
      request['Authorization'] = "AWS #{@aws_access_key_id}:#{signature}"
      request['AWS-Version']   = API_VERSION
      { :request  => request, 
        :server   => @params[:server],
        :port     => @params[:port],
        :protocol => @params[:protocol] }
    end
def generate_rest_request ( method , param ) queue_uri = param [ :queue_url ] ? URI ( param [ :queue_url ] ) . path : '/' message = param [ :message ] param . each { | key , value | param . delete ( key ) if ( value . nil? || key . is_a? ( Symbol ) ) } param_to_str = param . to_a . collect { | key , val | key . to_s + "=" + CGI :: escape ( val . to_s ) } . join ( "&" ) param_to_str = "?#{param_to_str}" unless param_to_str . right_blank? request = "Net::HTTP::#{method.capitalize}" . right_constantize . new ( "#{queue_uri}#{param_to_str}" ) request . body = message if message request [ 'content-md5' ] = '' request [ 'Content-Type' ] = 'text/plain' request [ 'Date' ] = Time . now . httpdate auth_string = "#{method.upcase}\n#{request['content-md5']}\n#{request['Content-Type']}\n#{request['Date']}\n#{CGI::unescape(queue_uri)}" signature = AwsUtils :: sign ( @aws_secret_access_key , auth_string ) request [ 'Authorization' ] = "AWS #{@aws_access_key_id}:#{signature}" request [ 'AWS-Version' ] = API_VERSION { :request => request , :server => @params [ :server ] , :port => @params [ :port ] , :protocol => @params [ :protocol ] } end
Generates a request hash for the REST API
Generates a request hash for the REST API
# :nodoc: # extract message body if nesessary # remove unset(=optional) and symbolyc keys # created request # set main headers # generate authorization string # set other headers # prepare output hash
method
<not_specific>
param
<not_specific>