Sha256: feb015cb91cb8e86bde401357bf49384f5a3feb13821dfe33ea91a8bea13075e

Contents?: true

Size: 478 Bytes

Versions: 3

Compression:

Stored size: 478 Bytes

Contents

module Idempo::RequestFingerprint
  def self.call(idempotency_key, rack_request)
    d = Digest::SHA256.new
    d << idempotency_key << "\n"
    d << rack_request.url << "\n"
    d << rack_request.request_method << "\n"
    d << rack_request.get_header("HTTP_AUTHORIZATION").to_s << "\n"
    while (chunk = rack_request.env["rack.input"].read(1024 * 65))
      d << chunk
    end
    Base64.strict_encode64(d.digest)
  ensure
    rack_request.env["rack.input"].rewind
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
idempo-1.2.2 lib/idempo/request_fingerprint.rb
idempo-1.2.1 lib/idempo/request_fingerprint.rb
idempo-1.1.0 lib/idempo/request_fingerprint.rb