Rainbows! Rack HTTP server user/dev discussion
 help / color / mirror / code / Atom feed
blob a70b33b022a2a76980a875d72629d3970d6db542 651 bytes (raw)
name: t/app_deferred.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
23
 
#\-E none
# can't use non-compatible middleware that doesn't pass "deferered?" calls
#
# used for testing deferred actions for Merb and possibly other frameworks
# ref: http://brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin

class DeferredApp < Struct.new(:app)
  def deferred?(env)
    env["PATH_INFO"] == "/deferred"
  end

  def call(env)
    env["rack.multithread"] or raise RuntimeError, "rack.multithread not true"
    body = "#{Thread.current.inspect}\n"
    headers = {
      "Content-Type" => "text/plain",
      "Content-Length" => body.size.to_s,
    }
    [ 200, headers, [ body ] ]
  end
end

run DeferredApp.new

debug log:

solving a70b33b ...
found a70b33b in https://yhbt.net/rainbows.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/rainbows.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).