<div dir="ltr">I created a pull for checking the return for the psgi.input file:  <a href="https://github.com/perl-catalyst/catalyst-runtime/pull/100">https://github.com/perl-catalyst/catalyst-runtime/pull/100</a><div><br></div><div>I created a ticket for HTTP::Body:  <a href="https://rt.cpan.org/Ticket/Display.html?id=105021">https://rt.cpan.org/Ticket/Display.html?id=105021</a></div><div><br></div><div>I&#39;ll create a separate pull for a config setting to make creating the psgi.input file optional when I have a bit of time.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 5, 2015 at 4:38 PM, Lasse Makholm <span dir="ltr">&lt;<a href="mailto:lasse@unity3d.com" target="_blank">lasse@unity3d.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Fri, Jun 5, 2015 at 8:26 PM, Bill Moseley <span dir="ltr">&lt;<a href="mailto:moseley@hank.org" target="_blank">moseley@hank.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div>Our app handles a lot of uploads, often quite large uploads.    As we know, uploads (and any non-parsed body) gets written to temp files via HTTP::Body.<div><br></div><div>Now, Catalyst::Request also writes every body to a temp file (via Stream::Buffered).   So, depending on the body size, can take up to twice the space in temp files as the content length.</div><div><br></div><div>If we are not going to use psgi.input and just use Catalyst&#39;s (HTTP::Body&#39;s) temp files could we make the creation of psgi.input optional?</div><div><br></div><div>I have a few other concerns about the current code.   </div><div><br></div><div>prepare_body in Catalyst::Request does not check the return code when it writes to the psgi.input file.   HTTP::Body also fails to check return codes when it writes.   This means if the partition where temp files are created fills then Catalyst request will ignore this and continue as if there&#39;s no problem.   I trust the risk here is recognized.</div><div><br></div><div>I think the fix in Catalyst::Request is pretty simple by checking return values:</div><div><br></div><div><div><font face="monospace, monospace">    # Check for definedness as you could read &#39;0&#39;</font></div><div><font face="monospace, monospace">    while ( defined ( my $chunk = $self-&gt;read() ) ) {</font></div><div><font face="monospace, monospace">        $self-&gt;prepare_body_chunk($chunk);</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">        next unless $stream_buffer;</font></div><div><font face="monospace, monospace">        $stream_buffer-&gt;print($chunk)</font></div><div><font face="monospace, monospace">            || die sprintf &quot;Failed to write %d bytes to psgi.input file: $!&quot;, length( $chunk );</font></div><div><font face="monospace, monospace">    }</font></div></div><div><div><br></div><div>HTTP::Body needs similar changes.</div></div></div></blockquote><div><br></div></span><div>On a related note, things like NFS mounted file systems tend to not guarantee that data is safely written to disk until all write() calls AND the final close() have completed successfully.</div><div><br></div><div>Code that checks that write() succeeds but then fails to do the same for close() is still broken.</div><div><br></div><div>Thanks for looking into this. Our app handles lots of large uploads too and I would love to see this fixed in HTTP::Body.</div><div><br></div><div>/L</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><div dir="ltr"><div><br></div><div><div>See any problem with making the psgi.input file optional?   And any reason not to throw an exception when writing to the temp file fails?<br></div><div><br></div><div>BTW -- Plack::Handler::Apache2 sets psgi.input to the Apache request object $r -- it would be handy to preserve this object for later use.</div><span><font color="#888888"><div><br></div><div><div><br></div>-- <br><div>Bill Moseley<br><a href="mailto:moseley@hank.org" target="_blank">moseley@hank.org</a></div>
</div></font></span></div></div>
<br></span>_______________________________________________<br>
List: <a href="mailto:Catalyst@lists.scsys.co.uk" target="_blank">Catalyst@lists.scsys.co.uk</a><br>
Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>
Searchable archive: <a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/" target="_blank">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>
Dev site: <a href="http://dev.catalyst.perl.org/" target="_blank">http://dev.catalyst.perl.org/</a><br>
<br></blockquote></div><br></div></div>
<br>_______________________________________________<br>
List: <a href="mailto:Catalyst@lists.scsys.co.uk">Catalyst@lists.scsys.co.uk</a><br>
Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>
Searchable archive: <a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/" target="_blank">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>
Dev site: <a href="http://dev.catalyst.perl.org/" target="_blank">http://dev.catalyst.perl.org/</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Bill Moseley<br><a href="mailto:moseley@hank.org" target="_blank">moseley@hank.org</a></div>
</div>