Sha256: 2b1a38e634faada91293002f35ff29151dc190253c3e9a50c378f8b30b8dc536

Contents?: true

Size: 990 Bytes

Versions: 26

Compression:

Stored size: 990 Bytes

Contents

#!/usr/bin/env ruby
# -*- encoding: binary -*-
# 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.
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" \
      "Connection: #{ENV["Connection"] || 'close'}\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

26 entries across 26 versions & 1 rubygems

Version Path
rainbows-5.2.1 t/bin/content-md5-put
rainbows-5.2.0 t/bin/content-md5-put
rainbows-5.1.1 t/bin/content-md5-put
rainbows-5.1.0 t/bin/content-md5-put
rainbows-5.0.0.5.ge717 t/bin/content-md5-put
rainbows-5.0.0 t/bin/content-md5-put
rainbows-4.7.0 t/bin/content-md5-put
rainbows-4.6.2 t/bin/content-md5-put
rainbows-4.6.1 t/bin/content-md5-put
rainbows-4.6.0.4.g4108 t/bin/content-md5-put
rainbows-4.6.0 t/bin/content-md5-put
rainbows-4.5.0 t/bin/content-md5-put
rainbows-4.4.3 t/bin/content-md5-put
rainbows-4.4.2 t/bin/content-md5-put
rainbows-4.4.1.1.gd5c8c t/bin/content-md5-put
rainbows-4.4.1 t/bin/content-md5-put
rainbows-4.4.0 t/bin/content-md5-put
rainbows-4.3.1 t/bin/content-md5-put
rainbows-4.3.0 t/bin/content-md5-put
rainbows-4.2.0 t/bin/content-md5-put