mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
23 lines
551 B
Ruby
Executable File
23 lines
551 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
# encoding: utf-8
|
|
while data = STDIN.gets # continuously read line from STDIN
|
|
next unless data
|
|
data = data.chomp # remove end of line symbol
|
|
|
|
decoded = [data].pack("H*") # decode base64 encoded request
|
|
|
|
# decoded value is raw HTTP payload, example:
|
|
#
|
|
# POST /post HTTP/1.1
|
|
# Content-Length: 7
|
|
# Host: www.w3.org
|
|
#
|
|
# a=1&b=2"
|
|
|
|
encoded = decoded.unpack("H*").first # encoding back to base64
|
|
|
|
# Emit request back
|
|
# You can skip this if want to filter out request
|
|
STDOUT.puts encoded
|
|
end
|