method
send_request_with_body_data
v2_2_9 -
Show latest stable
- Class:
Net::HTTPGenericRequest
send_request_with_body_data(sock, ver, path, params)private
No documentation available.
# File lib/net/http/generic_request.rb, line 209
def send_request_with_body_data(sock, ver, path, params)
if /\Amultipart\/form-data\z/ !~ self.content_type
self.content_type = 'application/x-www-form-urlencoded'
return send_request_with_body(sock, ver, path, URI.encode_www_form(params))
end
opt = @form_option.dup
require 'securerandom' unless defined?(SecureRandom)
opt[:boundary] ||= SecureRandom.urlsafe_base64(40)
self.set_content_type(self.content_type, boundary: opt[:boundary])
if chunked?
write_header sock, ver, path
encode_multipart_form_data(sock, params, opt)
else
require 'tempfile'
file = Tempfile.new('multipart')
file.binmode
encode_multipart_form_data(file, params, opt)
file.rewind
self.content_length = file.size
write_header sock, ver, path
IO.copy_stream(file, sock)
file.close(true)
end
end