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
1 change: 1 addition & 0 deletions lib/httparty/request/body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def normalize_query(query)
def content_body(object)
if file?(object)
object = (file = object).read
object.force_encoding(Encoding::UTF_8) if object.respond_to?(:force_encoding)
file.rewind if file.respond_to?(:rewind)
end

Expand Down
13 changes: 13 additions & 0 deletions spec/httparty/request/body_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@
it { is_expected.to eq multipart_params }

end

context 'when file is binary data and params contain non-ascii characters' do
let(:file) { File.open('spec/fixtures/tiny.gif', 'rb') }
let(:params) do
{
user: "Jöhn Döé",
enabled: true,
avatar: file,
}
end

it { expect { subject }.not_to raise_error }
end
end
end
end
Expand Down