Skip to content

Commit

Permalink
Add CRLF character to end of multipart body.
Browse files Browse the repository at this point in the history
Per RFC 2046 there is an optional CRLF character at the end
of the multipart-body to delimit between the body and optional
epilogue. Some server implementations break if this character is
not added.
  • Loading branch information
mhickman committed Sep 14, 2017
1 parent e362829 commit 3b6521f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/http/form_data/multipart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def glue

# @return [String]
def tail
@tail ||= "--#{@boundary}--"
@tail ||= "--#{@boundary}--#{CRLF}"
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/http/form_data/multipart_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def disposition(params)
"#{disposition 'name' => 'baz', 'filename' => file.filename}#{crlf}",
"Content-Type: #{file.content_type}#{crlf}",
"#{crlf}#{file}#{crlf}",
"--#{boundary_value}--"
"--#{boundary_value}--#{crlf}"
].join("")
end

Expand All @@ -44,7 +44,7 @@ def disposition(params)
"#{disposition 'name' => 'baz', 'filename' => file.filename}#{crlf}",
"Content-Type: #{file.content_type}#{crlf}",
"#{crlf}#{file}#{crlf}",
"--my-boundary--"
"--my-boundary--#{crlf}"
].join("")
end
end
Expand All @@ -61,7 +61,7 @@ def disposition(params)
"#{disposition 'name' => 'foo'}#{crlf}",
"Content-Type: #{part.content_type}#{crlf}",
"#{crlf}s#{crlf}",
"--#{boundary_value}--"
"--#{boundary_value}--#{crlf}"
].join("")
end
end
Expand All @@ -77,7 +77,7 @@ def disposition(params)
"--#{boundary_value}#{crlf}",
"#{disposition 'name' => 'foo'}#{crlf}",
"#{crlf}s#{crlf}",
"--#{boundary_value}--"
"--#{boundary_value}--#{crlf}"
].join("")
end
end
Expand Down

0 comments on commit 3b6521f

Please sign in to comment.