unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
blob 18af221c7011817bec4a360da27b31b793d31e72 651 bytes (raw)
name: t/preread_input.ru 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
#\-E none
require 'digest/md5'
require 'unicorn/preread_input'
use Unicorn::PrereadInput
nr = 0
run lambda { |env|
  $stderr.write "app dispatch: #{nr += 1}\n"
  input = env["rack.input"]
  dig = Digest::MD5.new
  if buf = input.read(16384)
    begin
      dig.update(buf)
    end while input.read(16384, buf)
    buf.clear # remove this call if Ruby ever gets escape analysis
  end
  if env['HTTP_TRAILER'] =~ /\bContent-MD5\b/i
    cmd5_b64 = env['HTTP_CONTENT_MD5'] or return [500, {}, ['No Content-MD5']]
    cmd5_bin = cmd5_b64.unpack('m')[0]
    return [500, {}, [ cmd5_b64 ] ] if cmd5_bin != dig.digest
  end
  [ 200, {}, [ dig.hexdigest ] ]
}

debug log:

solving 18af221 ...
found 18af221 in https://yhbt.net/unicorn.git/

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).