Class: AWS::SimpleWorkflow::Request

Inherits:
Core::Http::Request show all
Defined in:
lib/aws/simple_workflow/request.rb

Instance Attribute Summary collapse

Attributes inherited from Core::Http::Request

#access_key_id, #headers, #host, #http_method, #params, #path, #proxy_uri, #region, #service_ruby_name

Instance Method Summary collapse

Methods inherited from Core::Http::Request

#add_param, #initialize, #port, #port=, #querystring, #ssl_ca_file, #ssl_ca_file=, #ssl_ca_path, #ssl_ca_path=, #ssl_verify_peer=, #ssl_verify_peer?, #uri, #url_encoded_params, #use_ssl=, #use_ssl?

Constructor Details

This class inherits a constructor from AWS::Core::Http::Request

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



22
23
24
# File 'lib/aws/simple_workflow/request.rb', line 22

def body
  @body
end

Instance Method Details

#add_authorization!(signer) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/aws/simple_workflow/request.rb', line 24

def add_authorization!(signer)

  self.access_key_id = signer.access_key_id

  headers["x-amz-date"] ||= (headers["date"] ||= Time.now.rfc822)
  headers["host"] ||= host

  #raise ArgumentError, "a security token is required" unless
  #  signer.session_token
  #headers["x-amz-security-token"] = signer.session_token

  # compute the authorization
  request_hash = OpenSSL::Digest::SHA256.digest(string_to_sign)
  signature = signer.sign(request_hash)
  headers["x-amzn-authorization"] =
    "AWS3 "+
    "AWSAccessKeyId=#{signer.access_key_id},"+
    "Algorithm=HmacSHA256,"+
    "SignedHeaders=#{headers_to_sign.join(';')},"+
    "Signature=#{signature}"
end

#canonical_headersObject



53
54
55
56
57
58
# File 'lib/aws/simple_workflow/request.rb', line 53

def canonical_headers
  headers_to_sign.map do |name|
    value = headers[name]
    "#{name.downcase.strip}:#{value.strip}\n"
  end.sort.join
end

#headers_to_signObject



46
47
48
49
50
51
# File 'lib/aws/simple_workflow/request.rb', line 46

def headers_to_sign
  headers.keys.select do |header|
      header == "host" ||
      header =~ /^x-amz/
  end
end

#read_timeoutObject



68
69
70
71
72
73
74
75
# File 'lib/aws/simple_workflow/request.rb', line 68

def read_timeout
  # these two operations have long polling 
  if headers['x-amz-target'] =~ /PollFor(Decision|Activity)Task/
    90 
  else
    @read_timeout
  end
end

#string_to_signObject



60
61
62
63
64
65
66
# File 'lib/aws/simple_workflow/request.rb', line 60

def string_to_sign
  [http_method,
   "/",
   "",
   canonical_headers,
   body].join("\n")
end