From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 76AEC1960006 for ; Thu, 18 Jun 2015 03:19:46 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id BC09BB5D85E for ; Thu, 18 Jun 2015 03:42:22 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 0728797A82C for ; Thu, 18 Jun 2015 03:42:23 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Authentication-Results: funfun.nagaokaut.ac.jp (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=sendgrid.me Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ymboEXlTVR74 for ; Thu, 18 Jun 2015 03:42:22 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id CF4D697A82B for ; Thu, 18 Jun 2015 03:42:22 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 8390795243A for ; Thu, 18 Jun 2015 03:42:22 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 86E0212046D; Thu, 18 Jun 2015 03:42:19 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o2.heroku.sendgrid.net (o2.heroku.sendgrid.net [67.228.50.55]) by neon.ruby-lang.org (Postfix) with ESMTPS id CB05012043B for ; Thu, 18 Jun 2015 03:42:15 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=mODoVrgVYjwxRf6hC3jPbdJlX9c=; b=IbyQ4L9bTnL/V53jt9 o48QThrLwx7EHdu46TnCfJavdc1n4EA2Aa/GlNnvr1QCuVZIgYbfLVAL2B0lUSxn pY5vVeBxrkLbeTQCufB3dHHTNqlJZvAMMSDuqoo3r8hRjQwJDXRfRm6ggHCJhAJu 2sTWJSM58fpiyFyXlwLU4n6S0= Received: by filter0461p1mdw1.sendgrid.net with SMTP id filter0461p1mdw1.10924.5581BF7E1C 2015-06-17 18:42:06.691478575 +0000 UTC Received: from herokuapp.com (ec2-54-166-48-223.compute-1.amazonaws.com [54.166.48.223]) by ismtpd-052 (SG) with ESMTP id 14e02d406a8.23fa.2aee81 for ; Wed, 17 Jun 2015 18:42:06 +0000 (UTC) Date: Wed, 17 Jun 2015 18:42:06 +0000 From: me@julik.nl To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 44174 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11266 X-Redmine-Issue-Author: julik X-Redmine-Sender: julik X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS5coVX2aAdHtAoed1UBfcQofcEDAVXK3lJvDB Vl1lZpv4d3QEfIz4an7BeqhVwtZmEtG1r5hZ5K6nG3Eh+wCX0A7t425pxFSb4TPyXChql9vov+k3Tp 9hDWDFo6wVEkl6qp3vHlxh96EA2n0JttinR6 X-ML-Name: ruby-core X-Mail-Count: 69635 Subject: [ruby-core:69635] [Ruby trunk - Feature #11266] [PATCH] WEBrick: allow subclassing of Response and Request X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11266 has been updated by Julik Tarkhanov. No specific reason, only to make the changes to the library smaller. They certainly can be separate methods. ---------------------------------------- Feature #11266: [PATCH] WEBrick: allow subclassing of Response and Request https://bugs.ruby-lang.org/issues/11266#change-52989 * Author: Julik Tarkhanov * Status: Open * Priority: Normal * Assignee: ---------------------------------------- To properly support the Rack specification features introduced in 2013, a number of features is needed in HTTPResponse. * The Response should be able to handle it's socket to the given proc for writing (the socket control should be transferred to another routine). This is required for rack.hijack to work. * The Response assumes an "IO pull" model via read()/readpartial() for grabbing data from the body. Rack assumes a "push" model for writing the response, so having the ability to take over the socket is better for Rack as well. We can make a Fiber-based adapter to let an iterable object present itself like an IO to WEBrick but having direct socket control is much easier. * The Response should be able to take control of the chunking. This is currently done as a monkeypatch in Rack, but we much rather have it contained in the Response objects used by the Rack-supplied server handler. Rack currently solves it by giving WEBrick the read end of an IO pipe, which has a side effect of buffering the entire response even when direct socket operation is needed. This creates a situation where no Rack-based streaming servers can function (no long-polling, no server-sent-events, no large streamed responses via HTTP/FTP adapters etc.) Since all the three of those require patches to the HTTPResponse, a better approach would be to let the Server object create the right Response and let that response deal with the socket in a way it sees fit. This, however, is impossible at the moment because HTTPResponse and HTTPRequest are hardcoded in the main Server loop code, so if you want to override them with your implementations you have to override the entire service() method. If we let the Server object instantiate the Response and Request in it's own separate method a Server subclass could use customized versions of those. Pretty much the only downside is one extra method call per HTTP request. Rack could then use it's own Server subclass with the right Response and Request objects in place. I will be happy to provide a patch. ---Files-------------------------------- custom_req_response.patch (3.25 KB) -- https://bugs.ruby-lang.org/