Skip to content

Commit

Permalink
Fix immutable strings manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
ixti committed Jan 17, 2017
1 parent 149c1f8 commit e165f41
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 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 @@ -11,7 +11,7 @@ class Multipart
# @param [#to_h, Hash] data form data key-value Hash
def initialize(data)
@parts = Param.coerce FormData.ensure_hash data
@boundary = ("-" * 21) << SecureRandom.hex(21)
@boundary = (Array.new(21, "-") << SecureRandom.hex(21)).join("")
@content_length = nil
end

Expand Down
12 changes: 6 additions & 6 deletions lib/http/form_data/multipart/param.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ module FormData
class Multipart
# Utility class to represent multi-part chunks
class Param
CONTENT_DISPOSITION = ""

# @param [#to_s] name
# @param [FormData::File, #to_s] value
def initialize(name, value)
@name = name.to_s
@value = value

@name = name.to_s
@value = value
@header = "Content-Disposition: form-data; name=#{@name.inspect}"

return unless file?

@header << "; filename=#{value.filename.inspect}"
@header << CRLF
@header << "Content-Type: #{value.mime_type}"
@header = "#{@header}; filename=#{value.filename.inspect}#{CRLF}" \
"Content-Type: #{value.mime_type}"
end

# Returns body part with headers and data.
Expand Down

0 comments on commit e165f41

Please sign in to comment.