From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.229.70.129 with SMTP id d1cs144352qcj; Mon, 6 Jun 2011 19:37:43 -0700 (PDT) Return-Path: Received-SPF: pass (google.com: domain of rack-devel+bncCO7WupCxHRD1nbbvBBoEPB9-SQ@googlegroups.com designates 10.224.198.199 as permitted sender) client-ip=10.224.198.199; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rack-devel+bncCO7WupCxHRD1nbbvBBoEPB9-SQ@googlegroups.com designates 10.224.198.199 as permitted sender) smtp.mail=rack-devel+bncCO7WupCxHRD1nbbvBBoEPB9-SQ@googlegroups.com; dkim=pass header.i=rack-devel+bncCO7WupCxHRD1nbbvBBoEPB9-SQ@googlegroups.com Received: from mr.google.com ([10.224.198.199]) by 10.224.198.199 with SMTP id ep7mr1398353qab.59.1307414263161 (num_hops = 1); Mon, 06 Jun 2011 19:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:x-beenthere:mime-version:date:in-reply-to :references:user-agent:x-http-useragent:message-id:subject:from:to :x-original-sender:reply-to:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type :content-transfer-encoding; bh=dVOns4yFoB/Kr32q+q2pHVEYKxJ8nGrqlvm97V+XX3A=; b=xgsiq+zwG5IwZpbSwfs1QupCGpd1kuP34jYkHDXaFg8dsMLAHzBOSwEN463L6VkJKf Ykp4zvb9hc3q03xSA+9hrny63YiZ3xpGDg8LXK8bI6HFnCkkGxcnK6Q0QEGf/MGq8iho eu4GKurb39+LpLsas6t5aAjklwMVQuklFuzeo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-beenthere:mime-version:date:in-reply-to:references:user-agent :x-http-useragent:message-id:subject:from:to:x-original-sender :reply-to:precedence:mailing-list:list-id:x-google-group-id :list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type:content-transfer-encoding; b=NBuzUInvM5g5LVRxmn55fTxDFLmnxOArSfmfsQuqfluVWd/W4OC6e9L439NxFNgPR8 28/LQicAZVqid+KmoPcbbijhqHGLevozzyRj+1tkowujvs3aOfUv+lK+fuIjdMU+uMHF sONwKbqB7pcpCtSA/p9W3MhyTa7c0lccALmNY= Received: by 10.224.198.199 with SMTP id ep7mr408035qab.59.1307414261027; Mon, 06 Jun 2011 19:37:41 -0700 (PDT) X-BeenThere: rack-devel@googlegroups.com Received: by 10.224.187.71 with SMTP id cv7ls1078636qab.1.gmail; Mon, 06 Jun 2011 19:37:40 -0700 (PDT) Received: by 10.224.211.201 with SMTP id gp9mr1239828qab.2.1307414260599; Mon, 06 Jun 2011 19:37:40 -0700 (PDT) Received: by 10.224.96.6 with SMTP id f6msqan; Mon, 6 Jun 2011 10:05:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.7.79 with SMTP id c15mr597017vcc.50.1307379941530; Mon, 06 Jun 2011 10:05:41 -0700 (PDT) Received: by e21g2000vbz.googlegroups.com with HTTP; Mon, 6 Jun 2011 10:05:41 -0700 (PDT) Date: Mon, 6 Jun 2011 10:05:41 -0700 (PDT) In-Reply-To: <2cac8438-1819-4887-bce9-9a99578539db@f31g2000pri.googlegroups.com> References: <2cac8438-1819-4887-bce9-9a99578539db@f31g2000pri.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_5_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.10 Safari/535.1,gzip(gfe) Message-ID: Subject: Re: Middleware and post-request processing From: George To: Rack Development X-Original-Sender: george.ogata@gmail.com Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: X-Google-Group-Id: 486215384060 List-Post: , List-Help: , List-Archive: Sender: rack-devel@googlegroups.com List-Subscribe: , List-Unsubscribe: , Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Jun 3, 7:23=A0pm, ghazel wrote: > It seems to me that Rack is in need of a new post-response stage of > processing. This stage would occur after the response is fully written > and the client is unblocked, and before the next request is processed. > > Similar to what OobGC (http://bogomips.org/unicorn.git/tree/lib/unicorn/o= ob_gc.rb#n59 > ) accomplishes, it is sometimes useful to perform additional > operations after the response is written without blocking the client. > For example, the Oink middleware logs statistics about the request, > but blocks the response since it has no ability not to: (https://github.c= om/noahd1/oink/blob/4158d71bc9150f011072b2c6eefe73c72... > ). This processing takes time, and needlessly delays the response. > > This proposal would entail something like a single function which is > called on each middleware after the response is written to the client > and the socket is closed (depending on the server implementation). For > servers which have no ability to not block the client or delay further > requests the function should still be called, and the impact would be > similar to the behavior today. > > Thoughts? I'm very much in favor of adding such a hook also. I wrote a gem which does it for a bunch of common web servers: http://github.com/oggy/rack_after_reply . It adds a list of callback functions which just get added to the rack environment. I like this interface in that keeps the callbacks request-local, rather than just exposing a global hook. Beyond that, I'm totally open to suggestions. Of course I'd love it if web server authors would provide such a hook natively, or even maintain the adapter for their server in this gem. George