Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 946A8200CF7 for ; Tue, 19 Sep 2017 19:47:51 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8BEA01609DD; Tue, 19 Sep 2017 17:47:51 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A84C81609BF for ; Tue, 19 Sep 2017 19:47:50 +0200 (CEST) Received: (qmail 3871 invoked by uid 500); 19 Sep 2017 17:47:48 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 3860 invoked by uid 99); 19 Sep 2017 17:47:48 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Sep 2017 17:47:48 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id B4DABCF8B1 for ; Tue, 19 Sep 2017 17:47:47 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.381 X-Spam-Level: ** X-Spam-Status: No, score=2.381 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, HTML_OBFUSCATE_05_10=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id eFjeiDE-g3uv for ; Tue, 19 Sep 2017 17:47:45 +0000 (UTC) Received: from mail-ua0-f174.google.com (mail-ua0-f174.google.com [209.85.217.174]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id B7DB360D3F for ; Tue, 19 Sep 2017 17:47:44 +0000 (UTC) Received: by mail-ua0-f174.google.com with SMTP id g47so247661uad.0 for ; Tue, 19 Sep 2017 10:47:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=9kiaGvnrOIoAM9ivl1xojBqdzffXemi2rCVy/vEQzs8=; b=ZYusWvE08Lvxa+uQk5UMjmALcJTuRDpi6r2C3KMlM70oTqXkp0r1HEtYJoc1EM2rPJ RJrnJliJqBis4QeIsPKn4UKxXm7AKEAgch8683ixz3ex9n6JTOBherv633o5MUQ4lVnm hmAmPWa5Cq6chHnBYPR/AMZK5ybahlS5bgnGXhl2KQZo7l2pMjvTOYmE7zV6yHqzfq1H bbfYViL7XaLxfeSyLtWi6niTpskEfpx93QFJi1F4B4Zxt30t9mFedltYlO0UsqIOQOtn Iw43Qh3yJQdr5ft2ROXCXMd1n3O9/gkQDG8lOS8jKnzn3cM2T1fcSuCCkS9RsGGv5vF8 vtFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=9kiaGvnrOIoAM9ivl1xojBqdzffXemi2rCVy/vEQzs8=; b=HqRdk7TSHdtM2NPQ95hSoQn8OwBdlHgzG54sb9fgI/Ca+Zk80buNs8TlsAVvzencVN FVbHoJay+ZZQYk7BzvGuYf6yGcjf/tRzcdGMf/pZ91+lq4NHVy5aKBbPqsGfm+GQ2CB2 hC6ff/8/qxXCU8frZo56zqT4QX0KSz07SUgD3KHxx49kFL0zlUXbv08AupHqHU+uO39M JRt8Y5Dwq9wGSVwJUPdi2xzVHRWJMQX32dIPq8xaes+9RghK9GeuTitGk5kYJAf5/3mN tObqSbw5xYUDLiVu2xJ3D6EyFVkdEYhLqPyqx8fL+Rir6dQ6sIGgv/q4Z3yXNY/iiYL2 OZBg== X-Gm-Message-State: AHPjjUgyvKCFhK1rSlA/x2lcG6LIAwcIFvB4o8/2/3pvDil7jM1PwNpC ZzkJ+f5wHQoXfrS6w3cJka7ueKOr3X/s91+L/tzTzA== X-Google-Smtp-Source: AOwi7QBaUjCEwwvojv2t6UI2A6zLPzMBRAfryp1wigycGUGkco71hGuv6fhwxbBvwkV9upe4zFvmVC7a6PWCiVXx2s8= X-Received: by 10.176.0.21 with SMTP id 21mr2119829uai.39.1505843258417; Tue, 19 Sep 2017 10:47:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.78.232 with HTTP; Tue, 19 Sep 2017 10:47:38 -0700 (PDT) In-Reply-To: <141323ce-5d34-b18c-019b-6c6a175757aa@christopherschultz.net> References: <141323ce-5d34-b18c-019b-6c6a175757aa@christopherschultz.net> From: =?UTF-8?B?Vm9sa2FuIFlhesSxY8Sx?= Date: Tue, 19 Sep 2017 19:47:38 +0200 Message-ID: Subject: Re: [Bug 47410] Using Request#getStream() while reading parameters To: Tomcat Users List Content-Type: multipart/alternative; boundary="001a113d0a7281696705598e748d" archived-at: Tue, 19 Sep 2017 17:47:51 -0000 --001a113d0a7281696705598e748d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hey Christopher, Did not try (or consider) using a Tomcat Valve, since it would make the entire tool Tomcat-specific. I would rather find a way to solve the problem in a container agnostic way. Though, thanks for the idea. Maybe I can release a separate artifact just for Tomcat. Best. On Tue, Sep 19, 2017 at 7:11 PM, Christopher Schultz < chris@christopherschultz.net> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > Volkan, > > On 9/19/17 3:07 AM, Volkan Yaz=C4=B1c=C4=B1 wrote: > > Hello, > > > > When you try to access the raw InputStream of a > > x-www-form-urlencoded servlet request, the stream could have > > already been indirectly consumed by a prior access to the > > parameters (e.g., via ServletRequest#getParameterMap()) of the > > request. This feature (bug?) has already been documented in the > > section SRV.3.1.1 of the Servlet spec > > vlet-3_1-final.pdf> > > > > > and there are other people (Bug 47410 > > ) who have > > been bitten by this as well. > > > > This indirect stream consumption makes it, to the best of my > > knowledge, impossible to mirror the InputStream, which is exactly > > what we are trying to achieve in HRRS . > > Hence, I try to re-construct the InputStream from request > > parameters > > om/vlkan/hrrs/servlet/HrrsUrlEncodedFormHelper.java>. > > > > > This, as you can imagine, a really nasty hack which I am not fond of > > either. Further, to make the things worse, when servlet pushes the > > form parameters into request parameter map, it merges them with > > query parameters too. Now you need to manually parse both request > > and query parameters to figure out the initial form parameters. I > > am not even talking about lost parameter ordering. A total > > shipwreck. > > > > Even if HRRS is the first filter in the list, it is not consuming > > InputStream, it is just wrapping the InputStream and passing along > > the wrapped request along the chain. Problem is, getParameter() > > calls in Tomcat is using an internal reference to the InputStream > > (that is, o.a.c.connector.Request#getStream()) and not calling > > javax.servlet.ServletRequest#getInputStream(). Hence, InputStream > > gets indirectly consumed without the wrapped one getting used at > > all. Is it possible to make o.a.c.connector.Request#readPostBody() > > use getInputStream() rather than getStream() to solve this problem? > > Or is there an easier fix that I am missing? > > If you use a Valve (which is Tomcat-specific) instead of a Filter, are > you able to intercept input stream more effectively? > > - -chris > -----BEGIN PGP SIGNATURE----- > Comment: GPGTools - http://gpgtools.org > Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ > > iQIcBAEBCAAGBQJZwU/RAAoJEBzwKT+lPKRYIB4P/0J7Ok3e5CtJRewaHzM/BMv2 > fLCVhyrB79T0obwQMQ/Zh8A63mGsrzjpH+TJr8pvDlgXeWviT4JHgy01uf/KVt8/ > doHJAGvYMVkSM8ZnXRl2p940Rkw8hJKyTXXqE7fN2XilbxGBse3Q4OP2S61vb/EM > lgHJrSOdvElHyI+Wcdc/H46J/QNirYZx8PMHWl1ha9a1kw6YvOnJaFqK01KwMZR6 > ghUgbiOrP40gqEX8h8zKVYTMejZv2ngnN4worvN3Mp/PjTT2AvLAmgTVHFkHeX6J > HvVNh429YVpJEoCOiKuK7vSEI+YlpyVI9Emym5yi6yfXm7LTi2b8eNwx3jeRT09R > efiUhQWw4KFqBCVQPt5Jh5yjrl9Lzr9AfRIFphURvzCuHeT1qF6B+8zrE4njn4ch > az0PB8q6Okqykbii4BwFYd64cxHRzY0QuMaOqH5gGBcTHSEbk/7rw1Qah+vOG3/R > zt/cA51rgVwAO/jPUYFI1OcpO5vAJ7BTcejFFMCTlP3vLMz6PhhBM50P2fBaBleN > G09KgVNgWQV3hQgOdmbTiOMc775EsLHwv9DMWwTxwsDvAVPmUEZTa4DqM3rqe8hx > QlCjvO7fPilrgy9f6ryH0dfioSpZXUAYhADnhvX98dRbuB3cWooIbLbaTAMgIzBe > KbEM3Ii+bGaox7k4UKeC > =3Do2M4 > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > > --001a113d0a7281696705598e748d--