From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E586B1F833 for ; Sun, 25 Dec 2022 12:23:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yhbt.net; s=selector1; t=1671971031; bh=tQ2TEjYHYn8/Dh69tMZSrSdqAb2oVvGGT7WWMRMockc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JoDugM86KdORDVWcmensHYSUUpF9wVIpltWXsZR00NDfoOQQCAtBzUWFDriRTlK34 TfwttNRdF7hJRk9McgQXNkEewlaG3fSIxzps7lyTnQTv3dIj9Q8cdRBfRClg7TeSFJ 4rK3HMr2rE5AO3pcg1KkP97f8Ahy9OUPB0sbEqNY= From: Eric Wong To: yahns-public@yhbt.net Subject: [PATCH 1/2] extras/exec_cgi: fix for newer Rack::ContentLength Date: Sun, 25 Dec 2022 12:23:50 +0000 Message-Id: <20221225122351.4799-2-bofh@yhbt.net> In-Reply-To: <20221225122351.4799-1-bofh@yhbt.net> References: <20221225122351.4799-1-bofh@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Rack::ContentLength now unconditionally captures bodies and doesn't dup the data yield by body#each. Thus we can't reuse buffers anymore. --- extras/exec_cgi.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extras/exec_cgi.rb b/extras/exec_cgi.rb index 8a1939d..a04087d 100644 --- a/extras/exec_cgi.rb +++ b/extras/exec_cgi.rb @@ -34,14 +34,15 @@ def initialize(rd) def each buf = @body_tip yield buf unless buf.empty? + buf = @body_tip = nil - case tmp = @rd.read_nonblock(8192, buf, exception: false) + case tmp = @rd.read_nonblock(8192, exception: false) when :wait_readable @rd.wait_readable when nil break else # String - yield tmp + yield tmp.freeze end while true self ensure @@ -117,7 +118,7 @@ def call(env) tmp.clear end head, body = head.split(/\r?\n\r?\n/, 2) - io.body_tip = body + io.body_tip = body.freeze env["HTTP_VERSION"] ||= "HTTP/1.0" # stop Rack::Chunked for HTTP/0.9