Skip to content

Commit

Permalink
Add the ability to set Content-ID header for ParamPart
Browse files Browse the repository at this point in the history
  • Loading branch information
ethnt authored and ioquatix committed Jun 26, 2019
1 parent a7d238f commit 475c97f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/parts.rb
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions spec/parts_spec.rb
Expand Up @@ -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

0 comments on commit 475c97f

Please sign in to comment.