From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.229.96.67 with SMTP id g3csp235344qcn; Tue, 5 Jun 2012 10:07:29 -0700 (PDT) Return-Path: Received-SPF: pass (google.com: domain of rack-devel+bncCOyd0PeqBxDR-bj-BBoENqwdcg@googlegroups.com designates 10.50.216.164 as permitted sender) client-ip=10.50.216.164; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rack-devel+bncCOyd0PeqBxDR-bj-BBoENqwdcg@googlegroups.com designates 10.50.216.164 as permitted sender) smtp.mail=rack-devel+bncCOyd0PeqBxDR-bj-BBoENqwdcg@googlegroups.com; dkim=pass header.i=rack-devel+bncCOyd0PeqBxDR-bj-BBoENqwdcg@googlegroups.com Received: from mr.google.com ([10.50.216.164]) by 10.50.216.164 with SMTP id or4mr2972555igc.1.1338916049544 (num_hops = 1); Tue, 05 Jun 2012 10:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=x-beenthere:date:from:to:message-id:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=SMXJxG330Ce1kdY79ioDvVupwqBewuqraxT6R7Lr/+E=; b=vf2PMjCRjpzeAQwJSCUKegYLp9QgLZ+pGaHWPH/mXowayr9O5V50buYdZPLZWq8ayq HNT67H42N5yXoZWp2E8AAwaZJxZojqRZj5S5FB0FVz7MBxRm1HgjLWRxjtE0dxVmSaXn y2Y1wJ2FCTcWdO4+jY0e6P+Uhy4UDtYtbp6Xs= Received: by 10.50.216.164 with SMTP id or4mr423060igc.1.1338916049471; Tue, 05 Jun 2012 10:07:29 -0700 (PDT) X-BeenThere: rack-devel@googlegroups.com Received: by 10.231.80.14 with SMTP id r14ls5467160ibk.4.gmail; Tue, 05 Jun 2012 10:07:27 -0700 (PDT) Received: by 10.50.171.67 with SMTP id as3mr2346451igc.5.1338916047727; Tue, 05 Jun 2012 10:07:27 -0700 (PDT) Received: by 10.50.82.3 with SMTP id e3msigy; Tue, 5 Jun 2012 10:05:02 -0700 (PDT) Received: by 10.68.194.230 with SMTP id hz6mr2741196pbc.4.1338915902156; Tue, 05 Jun 2012 10:05:02 -0700 (PDT) Date: Tue, 5 Jun 2012 10:05:00 -0700 (PDT) From: David LaMacchia To: rack-devel@googlegroups.com Message-Id: Subject: .eql? returns false on identity comparison of Tempfiles MIME-Version: 1.0 X-Original-Sender: dml@copious.com Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: X-Google-Group-Id: 486215384060 List-Post: , List-Help: , List-Archive: Sender: rack-devel@googlegroups.com List-Subscribe: , List-Unsubscribe: , Content-Type: multipart/alternative; boundary="----=_Part_169_17372075.1338915900946" ------=_Part_169_17372075.1338915900946 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit I ran into an unusual problem (rails 3.1.3, rack 1.3.6) while using rack-multipart_related (https://github.com/lucasfais/rack-multipart_related) as middleware to handle parsing of a multipart containing an image. While parsing the POST request, there's the following code in rack/request.rb: def POST if @env["rack.input"].nil? raise "Missing rack.input" elsif @env["rack.request.form_input"].eql? @env["rack.input"] @env["rack.request.form_hash"] elsif form_data? || parseable_data? I noticed that if the size of the image was small, a StringIO is created containing the request data and as expected, @env["rack.request.form_input"].eql? @env["rack.input"] returns true. Both operands point to the same StringIO, the object_id's are the same. If the image being uploaded was larger, a Tempfile seems to be created for the input and I get a weird result in this same piece of code: (rdb:1) p @env["rack.request.form_input"] # (rdb:1) p @env["rack.request.form_input"].class Tempfile (rdb:1) p @env["rack.request.form_input"].object_id 70289039522540 (rdb:1) p @env["rack.input"] # (rdb:1) p @env["rack.input"].object_id 70289039522540 (rdb:1) p @env["rack.request.form_input"] == @env["rack.input"] true (rdb:1) p @env["rack.request.form_input"].eql?(@env["rack.input"]) false So, == returns that the operands, which are the same Tempfile, are equivlent, but .eql? returns false. I have a couple questions... 1) Anyone have any idea what might cause this? 2) What controls whether a StringIO or Tempfile is created when parsing a request object? Thanks! dave ------=_Part_169_17372075.1338915900946 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable I ran into an unusual problem (rails 3.1.3, rack 1.3.6) while using rack-mu= ltipart_related (https://github.com/lucasfais/rack-multipart_related) as mi= ddleware to handle parsing of a multipart containing an image. While parsin= g the POST request, there's the following code in rack/request.rb:

=
    def POST
      if @e= nv["rack.input"].nil?
        raise "Missing = rack.input"
      elsif @env["rack.request.form_in= put"].eql? @env["rack.input"]
        @env["r= ack.request.form_hash"]
      elsif form_data? || = parseable_data?

I noticed that if the size o= f the image was small, a StringIO is created containing the request data an= d as expected,

@env["rack.request.form_input"].eql= ? @env["rack.input"]

returns true.  Both oper= ands point to the same StringIO, the object_id's are the same.
If the image being uploaded was larger, a Tempfile seems to be= created for the input and I get a weird result in this same piece of code:=

(rdb:1) p @env["rack.request.form_input"]
#<File:/var/folders/_c/0c66qtcm8xjcns006s6bhgzr0000gn/T/thin-bod= y20120604-68121-12dpbf1>
(rdb:1) p @env["rack.request.form_inp= ut"].class
Tempfile
(rdb:1) p @env["rack.request.form_i= nput"].object_id
70289039522540
(rdb:1) p @env["rack.in= put"]
#<File:/var/folders/_c/0c66qtcm8xjcns006s6bhgzr0000gn/T/= thin-body20120604-68121-12dpbf1>
(rdb:1) p @env["rack.input"].= object_id
70289039522540
(rdb:1) p @env["rack.request.f= orm_input"] =3D=3D @env["rack.input"]
true
(rdb:1) p @e= nv["rack.request.form_input"].eql?(@env["rack.input"])
false

So, =3D=3D returns that the operands, which are = the same Tempfile, are equivlent, but .eql? returns false.

I have a couple questions...

1) Anyone ha= ve any idea what might cause this?
2) What controls whether a Str= ingIO or Tempfile is created when parsing a request object?

<= /div>
Thanks!

dave
------=_Part_169_17372075.1338915900946--