lib/ey-hmac/adapter/faraday.rb in ey-hmac-0.0.2 vs lib/ey-hmac/adapter/faraday.rb in ey-hmac-0.0.3
- old
+ new
@@ -2,17 +2,21 @@
def method
request[:method].to_s.upcase
end
def content_type
- %w[CONTENT-TYPE CONTENT_TYPE Content-Type Content_Type].inject(nil){|r, h| r || request[h]}
+ %w[CONTENT-TYPE CONTENT_TYPE Content-Type Content_Type].inject(nil){|r, h| r || request[:request_headers][h]}
end
def content_digest
- existing = %w[CONTENT-DIGEST CONTENT_DIGEST Content-Digest Content_Digest].inject(nil){|r,h| r || request[:request_headers][h]}
- existing || (request[:request_headers]['Content-Digest'] = (body && Digest::MD5.hexdigest(body)))
+ if existing = %w[CONTENT-DIGEST CONTENT_DIGEST Content-Digest Content_Digest].inject(nil){|r,h| r || request[:request_headers][h]}
+ existing
+ elsif digestable = body && Digest::MD5.hexdigest(body)
+ request[:request_headers]['Content-Digest'] = digestable
+ else nil
+ end
end
-
+
def body
if request[:body] && request[:body].to_s != ""
request[:body]
else nil
end