Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 17 lines (16 sloc) 509 Bytes
#!/usr/bin/env ruby
#
# Usage: curl-har [ARGS_FOR_CURL]... < HAR
#
# Replay HAR given on stdin using curl(1).
#
# Written in 2012 by Suraj N. Kurapati :-)
# who's found at https://github.com/sunaku
#
rip = ->(hash){ hash.to_a.transpose.last }
require 'json'
req = JSON.load(STDIN.read)['request']
hdr = req['headers'].flat_map {|h| ['-H', rip[h].join(?:)] }
arg = req['queryString'].flat_map {|q| ['-d', rip[q].join(?=)] }
get = '-G' if req['method'] == 'GET'
exec 'curl', *hdr, *arg, *get, req['url'], *ARGV