From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.142.140.7 with SMTP id n7cs44246wfd; Thu, 5 Nov 2009 15:25:13 -0800 (PST) Received-SPF: pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.220.88.8 as permitted sender) client-ip=10.220.88.8; Authentication-Results: mr.google.com; spf=pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.220.88.8 as permitted sender) smtp.mail=grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com; dkim=pass header.i=grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com Received: from mr.google.com ([10.220.88.8]) by 10.220.88.8 with SMTP id y8mr149073vcl.36.1257463513177 (num_hops = 1); Thu, 05 Nov 2009 15:25:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to :received:received:received:received-spf:received:dkim-signature :domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type :content-transfer-encoding:reply-to:sender:precedence:x-google-loop :mailing-list:list-id:list-post:list-help:list-unsubscribe :x-beenthere-env:x-beenthere; bh=hkNnXgeqwoOMuzJ9WOAh8VdfsWwZdWAXf1b5Ah8ITYg=; b=mmx/2j+VaSpfgK2BpCjcnrfXfIcgzak4/rJ+rw9BvVNP7NDqgaCWpb9LO4aoep76TK xCeWqyUDx9r7xcor8pbgd+56GqXpp/e2ZOeuinzE7s4NGFV7YBhIyr0OJAsys3NPLw68 iaGaX/Srj7FqkoD/7kNwNdkO2OAF/CSdJ/GsI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:received-spf:authentication-results :dkim-signature:domainkey-signature:mime-version:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding:reply-to:sender:precedence:x-google-loop :mailing-list:list-id:list-post:list-help:list-unsubscribe :x-beenthere-env:x-beenthere; b=q6OMhLfh4IWZOVU6LdDrTBinELiuWgsZ0ennkBYNM38/0+RuU/xhnsFDiK6s1yn+/X q6U47bNd7aoRjScQwFMoh1U/eSTQm5lfNXGTrkTB5HJsmggdP5cBm6GDvy3bm48fsLNc bJeeF9d2AwDgj+cc2xlIq6BJlTNP/QR3/NOjI= Received: by 10.220.88.8 with SMTP id y8mr10391vcl.36.1257463513097; Thu, 05 Nov 2009 15:25:13 -0800 (PST) Received: by 10.230.11.82 with SMTP id s18gr1717vbs.0; Thu, 05 Nov 2009 15:25:04 -0800 (PST) X-Sender: martin.aumont@gmail.com X-Apparently-To: rack-devel@googlegroups.com Received: by 10.213.44.1 with SMTP id y1mr351566ebe.12.1257463502453; Thu, 05 Nov 2009 15:25:02 -0800 (PST) Received: by 10.213.44.1 with SMTP id y1mr351565ebe.12.1257463502427; Thu, 05 Nov 2009 15:25:02 -0800 (PST) Return-Path: Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.27]) by gmr-mx.google.com with ESMTP id 16si2173568ewy.3.2009.11.05.15.25.01; Thu, 05 Nov 2009 15:25:01 -0800 (PST) Received-SPF: pass (google.com: domain of martin.aumont@gmail.com designates 74.125.78.27 as permitted sender) client-ip=74.125.78.27; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of martin.aumont@gmail.com designates 74.125.78.27 as permitted sender) smtp.mail=martin.aumont@gmail.com; dkim=pass (test mode) header.i=@gmail.com Received: by ey-out-2122.google.com with SMTP id 9so144333eyd.5 for ; Thu, 05 Nov 2009 15:25:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=LcYH0vV778zqFiz6W2ARlzuo+eJMsN7yeM41uEqwNMQ=; b=OYoy+W8WopuyQsXtdkpCCHRt1VO44bqzhw87ufY7tTSk1xViu/Lc/CCpKnkmIyqf2L nBSatdfCQB2FK/98hDzR+XroSpIBXlqYGOomIxcgvsCAP8H6JIONezalcOdB1j5qRC+I ppbOiMspKBv3lS7svmuJIBP7I3xLmUTkGZ1xg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=xozajeNC2GEs8172E99nuRmTEEbyB6lOj/Zl1a+Ol2X8lDLxwCJkBsPfnX1SIik/Em SRIZM9BZcd6yDpaer2pQJyzfns0qGNl1OgNdGdXxZjgprIfB4ngiCNzBlr1OqO8R1yZW V4+m1s3mEqLW5iGN943ZKIGh117peNrp7j5nM= MIME-Version: 1.0 Received: by 10.216.90.79 with SMTP id d57mr1038686wef.117.1257463501226; Thu, 05 Nov 2009 15:25:01 -0800 (PST) In-Reply-To: <200911052332.39227.ibc@aliax.net> References: <50c7f5da-ba10-4552-9e19-64cf8ede1211@k17g2000yqb.googlegroups.com> <200911052332.39227.ibc@aliax.net> From: Martin Date: Thu, 5 Nov 2009 18:24:41 -0500 Message-ID: <104b9b200911051524k5074c1b1j7b9398fae579b0fc@mail.gmail.com> Subject: Re: Using Rack Middlware to filter parameters To: rack-devel@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Reply-To: rack-devel@googlegroups.com Sender: rack-devel@googlegroups.com Precedence: bulk X-Google-Loop: groups Mailing-List: list rack-devel@googlegroups.com; contact rack-devel+owner@googlegroups.com List-Id: List-Post: List-Help: List-Unsubscribe: , X-BeenThere-Env: rack-devel@googlegroups.com X-BeenThere: rack-devel@googlegroups.com An example of rack middleware that modifies the request: http://github.com/mynyml/rack-abstract-format/blob/master/lib/rack/abstract= _format.rb On Thu, Nov 5, 2009 at 5:32 PM, I=C3=B1aki Baz Castillo wro= te: > > El Jueves, 5 de Noviembre de 2009, RobL escribi=C3=B3: >> Hi there, >> >> I wanted to ask if anyone could point me in the direction of some code >> examples where you can use Rack Middleware to filter incoming >> parameters. > >> But as a very tivial example I want be able to do something like >> >> module Rack >> =C2=A0 class Myfilter >> =C2=A0 =C2=A0 def initialize(app) >> =C2=A0 =C2=A0 =C2=A0 @app =3D app >> =C2=A0 =C2=A0 end >> >> =C2=A0 =C2=A0 def call(env) >> =C2=A0 =C2=A0 =C2=A0 =C2=A0request =3D Rack::Request.new(env) >> =C2=A0 =C2=A0 =C2=A0 =C2=A0request.params.delete('someparam') >> =C2=A0 =C2=A0 =C2=A0 =C2=A0# but at this point I want/need to modify env >> =C2=A0 =C2=A0 =C2=A0 =C2=A0@app.call(env) >> =C2=A0 =C2=A0 end >> =C2=A0 end >> end >> >> I'm not sure how I'd then get the modified env back, do you have to >> literally modify something like env['query_string'], also at this >> point the content length would be different so I'd have to update that >> also. > > Do you mean parameters in the request URI? or in the body? in the first c= ase > the content-length should not be modified. > > >> Most of the applications I've seen are an endpoint and an app in >> itself than sitting in the middle of the incoming request, and I'm yet >> to find an example of modifying the incoming params. > > I expect that Rack is not designed for that, as changing the request is n= ot a > very common usage (IMHO). > > -- > I=C3=B1aki Baz Castillo >