Skip to content

Commit

Permalink
Fix multipart uploads with boolean params.
Browse files Browse the repository at this point in the history
  • Loading branch information
rywall committed Feb 24, 2018
1 parent 829b477 commit 7c68f9e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/httparty/request/body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def generate_multipart
memo += "\r\n"
memo += "Content-Type: application/octet-stream\r\n" if file?(value)
memo += "\r\n"
memo += file?(value) ? value.read : value
memo += file?(value) ? value.read : value.to_s
memo += "\r\n"
end

Expand Down
7 changes: 6 additions & 1 deletion spec/httparty/request/body_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
user: {
avatar: File.open('spec/fixtures/tiny.gif'),
first_name: 'John',
last_name: 'Doe'
last_name: 'Doe',
enabled: true
}
}
end
Expand All @@ -45,6 +46,10 @@
"Content-Disposition: form-data; name=\"user[last_name]\"\r\n" \
"\r\n" \
"Doe\r\n" \
"--------------------------c772861a5109d5ef\r\n" \
"Content-Disposition: form-data; name=\"user[enabled]\"\r\n" \
"\r\n" \
"true\r\n" \
"--------------------------c772861a5109d5ef--\r\n"
end

Expand Down

0 comments on commit 7c68f9e

Please sign in to comment.