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 9F5891A60098 for ; Fri, 24 Jun 2016 02:13:27 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 05303B5D8F2 for ; Fri, 24 Jun 2016 02:48:21 +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 059A418CC81A for ; Fri, 24 Jun 2016 02:48:20 +0900 (JST) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id B71621204DC; Fri, 24 Jun 2016 02:48:18 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id E7D4B12047A for ; Fri, 24 Jun 2016 02:48:14 +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=eHEqK2FJLmkDdCtpyaqatVWiwXY=; b=XR46XjoufQXNGmJWQk cvapGLnX0SOgVQgJMcyR0zLkPkrYvS3imoLxhMt60YrzpsGnJI1qqnrWtHYl5QHp cQi+z/oZK54hqrktPpRd/nNx+4xDEnVxavzVCb8FOdA5sqzrQMS5N+CwdJhxsgRA 4rawSqNkx8wG+Evrc8mlXDSKU= Received: by filter0815p1mdw1.sendgrid.net with SMTP id filter0815p1mdw1.1024.576C20A522 2016-06-23 17:47:17.939649359 +0000 UTC Received: from herokuapp.com (ec2-54-87-67-136.compute-1.amazonaws.com [54.87.67.136]) by ismtpd0002p1iad1.sendgrid.net (SG) with ESMTP id G3Lixc4cRAG2JjJS_tHtlw for ; Thu, 23 Jun 2016 17:47:17.739 +0000 (UTC) Date: Thu, 23 Jun 2016 17:47:17 +0000 From: me@julik.nl To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 50838 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11266 X-Redmine-Issue-Author: julik X-Redmine-Issue-Assignee: nahi 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS7a2uyxDA7uDx2Bl5Qpygra4TOAO1d6zmZyb4 /93EsQziScUvcl2o12fGQuXVt7bopYNSdO1jMZchIPf6B3T/EqiCSPQsvyJn/qyHNnsNWX75JsxK/c eyC4jU+/ie3jb+SIJKH9r2i39a/L7eZRCYRI X-ML-Name: ruby-core X-Mail-Count: 76121 Subject: [ruby-core:76121] [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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11266 has been updated by Julik Tarkhanov. It has been a year. Is there still anything I can do/change? ---------------------------------------- Feature #11266: [PATCH] WEBrick: allow subclassing of Response and Request https://bugs.ruby-lang.org/issues/11266#change-59325 * Author: Julik Tarkhanov * Status: Assigned * Priority: Normal * Assignee: Hiroshi Nakamura ---------------------------------------- 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) req_response_sub2.patch (2.54 KB) -- https://bugs.ruby-lang.org/