Skip to content

Instantly share code, notes, and snippets.

@bjeanes
Last active November 2, 2018 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjeanes/63580e27c197885d4b07160fae132108 to your computer and use it in GitHub Desktop.
Save bjeanes/63580e27c197885d4b07160fae132108 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'tempfile'
require 'securerandom'
endpoint = ARGV.shift || 'http://localhost:3000/'
parts = Integer(ARGV.shift || 10_000)
boundary = SecureRandom.hex(20)
data = (1..parts).map do |i|
<<~STR.gsub(/\n/, "\r\n")
--"#{boundary}"
Content-Disposition: form-data; name="a"
1
STR
end.join("\r\n")
data << "--#{boundary}--\r\n"
Tempfile.open('request-body') do |f|
f.write(data)
system(
'curl', '-s', '-o', '/dev/null', '-v', '--trace-time',
'-H', "Content-Type: multipart/form-data; boundary=#{boundary}",
'--data-binary', "@#{f.path}",
endpoint,
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment