Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/httparty/request/streaming_multipart_body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ def build_part_header(key, value, is_file)
header << %(; filename="#{file_name(value).gsub(/["\r\n]/, replacement_table)}").b
header << NEWLINE.b
header << "Content-Type: #{content_type(value)}#{NEWLINE}".b
else
header << NEWLINE.b
end
header << NEWLINE.b
header
Expand Down
4 changes: 2 additions & 2 deletions spec/httparty/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,14 @@
allow(HTTParty::Request::MultipartBoundary).to receive(:generate).and_return('test-boundary-123')

# Get streaming content
request1 = HTTParty::Request.new(Net::HTTP::Post, 'http://api.foo.com/v1', body: { avatar: file })
request1 = HTTParty::Request.new(Net::HTTP::Post, 'http://api.foo.com/v1', body: { avatar: file, first_name: "John" })
request1.send(:setup_raw_request)
streaming_content = request1.instance_variable_get(:@raw_request).body_stream.read

file.rewind

# Get non-streaming content
request2 = HTTParty::Request.new(Net::HTTP::Post, 'http://api.foo.com/v1', body: { avatar: file }, stream_body: false)
request2 = HTTParty::Request.new(Net::HTTP::Post, 'http://api.foo.com/v1', body: { avatar: file, first_name: "John" }, stream_body: false)
request2.send(:setup_raw_request)
non_streaming_content = request2.instance_variable_get(:@raw_request).body

Expand Down
Loading