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 2393A17D6C89 for ; Wed, 17 Jun 2015 09:45:54 +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 6623CB5D934 for ; Wed, 17 Jun 2015 10:08:20 +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 79B7997A82B for ; Wed, 17 Jun 2015 10:08:21 +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 sXUT_xSGFHdn for ; Wed, 17 Jun 2015 10:08:21 +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 56FD097A826 for ; Wed, 17 Jun 2015 10:08: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 3861895243E for ; Wed, 17 Jun 2015 10:08:20 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 8FE59120466; Wed, 17 Jun 2015 10:08: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 765FC12045C for ; Wed, 17 Jun 2015 10:08: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=eEEfHgvhnjuPAJ2vV7Y3bHFvuys=; b=CQbOa6vXr+DmVkdkyx v8oYrUVmHZuuwHKVp/Sncvu1YUPOfWq7JvhTaUsk/Ow5iJLK3uiF7vbrhdaR6Wdu Z3NmVd9TNkIa40n816cDCtU0vEdFkvTAQmc4TOIenzK5PVajzzH4vBUUvnfyebKs xFF16NntHIKF1Nycjce8Fqnn0= Received: by filter0443p1mdw1.sendgrid.net with SMTP id filter0443p1mdw1.7093.5580C878D 2015-06-17 01:08:11.189356304 +0000 UTC Received: from herokuapp.com (ec2-54-211-17-185.compute-1.amazonaws.com [54.211.17.185]) by ismtpd-034 (SG) with ESMTP id 14dff0f20df.2f78.c37d7 for ; Wed, 17 Jun 2015 01:08:11 +0000 (UTC) Date: Wed, 17 Jun 2015 01:08:11 +0000 From: nobu@ruby-lang.org 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: 44157 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11266 X-Redmine-Issue-Author: julik X-Redmine-Sender: nobu 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS7ZbMckw8NlRGEEbvcl7/gtB8RhzKyYDOoAos sY2KdncrU/6DiU+olJ3LUZF8HIGBxgApLne8eX7hu1g6/M9Di7fW2rV1pOM0Onc/WfHMCj/2W3qq5K dE/EiLrxHEOwHmU= X-ML-Name: ruby-core X-Mail-Count: 69624 Subject: [ruby-core:69624] [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 Nobuyoshi Nakada. Any reason to create both together in `create_request_and_response`? ---------------------------------------- Feature #11266: [PATCH] WEBrick: allow subclassing of Response and Request https://bugs.ruby-lang.org/issues/11266#change-52969 * 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/