Sha256: f742de2c5010ed9f67f756f5fd03f1ed86575da0d8de539f111349011aa9a67d

Contents?: true

Size: 932 Bytes

Versions: 9

Compression:

Stored size: 932 Bytes

Contents

#!/usr/bin/env ruby
# simple chunked HTTP PUT request generator (and just that),
# it reads stdin and writes to stdout so socat can write to a
# UNIX or TCP socket (or to another filter or file) along with
# a Content-MD5 trailer.
# -*- encoding: binary -*-
require 'digest/md5'
$stdout.sync = $stderr.sync = true
$stdout.binmode
$stdin.binmode

bs = ENV['bs'] ? ENV['bs'].to_i : 4096

if ARGV.grep("--no-headers").empty?
  $stdout.write(
      "PUT / HTTP/1.1\r\n" \
      "Host: example.com\r\n" \
      "Transfer-Encoding: chunked\r\n" \
      "Trailer: Content-MD5\r\n" \
      "\r\n"
    )
end

digest = Digest::MD5.new
if buf = $stdin.readpartial(bs)
  begin
    digest.update(buf)
    $stdout.write("%x\r\n" % [ buf.size ])
    $stdout.write(buf)
    $stdout.write("\r\n")
  end while $stdin.read(bs, buf)
end

digest = [ digest.digest ].pack('m').strip
$stdout.write("0\r\n")
$stdout.write("Content-MD5: #{digest}\r\n\r\n")

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rainbows-0.90.1 t/bin/content-md5-put
rainbows-0.90.0 t/bin/content-md5-put
rainbows-0.9.0 t/bin/content-md5-put
rainbows-0.8.0 t/bin/content-md5-put
rainbows-0.7.0 t/bin/content-md5-put
rainbows-0.6.0 t/bin/content-md5-put
rainbows-0.5.0 t/bin/content-md5-put
rainbows-0.4.0 t/bin/content-md5-put
rainbows-0.3.0 t/bin/content-md5-put