From 475c97ffd7e5bafcd620d026151dfc26c6f5ddf0 Mon Sep 17 00:00:00 2001 From: Ethan Turkeltaub Date: Wed, 26 Jun 2019 16:46:08 -0400 Subject: [PATCH] Add the ability to set Content-ID header for ParamPart --- lib/parts.rb | 1 + spec/parts_spec.rb | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/parts.rb b/lib/parts.rb index ee46c72..351cfce 100644 --- a/lib/parts.rb +++ b/lib/parts.rb @@ -52,6 +52,7 @@ def length def build_part(boundary, name, value, headers = {}) part = '' part << "--#{boundary}\r\n" + part << "Content-ID: #{headers["Content-ID"]}\r\n" if headers["Content-ID"] part << "Content-Disposition: form-data; name=\"#{name.to_s}\"\r\n" part << "Content-Type: #{headers["Content-Type"]}\r\n" if headers["Content-Type"] part << "\r\n" diff --git a/spec/parts_spec.rb b/spec/parts_spec.rb index ceaab6e..b542c04 100644 --- a/spec/parts_spec.rb +++ b/spec/parts_spec.rb @@ -99,4 +99,9 @@ def content_type; 'application/data'; end it "test_correct_length" do assert_part_length @part end + + it "test_content_id" do + part = Parts::ParamPart.new("boundary", "with_content_id", "foobar", "Content-ID" => "id") + expect(part.to_io.read).to match(/Content-ID: id/) + end end