Plack::Util ate my Content-Length

45 views
Skip to first unread message

fluff...@googlemail.com

unread,
Dec 21, 2012, 11:52:57 AM12/21/12
to psgi-...@googlegroups.com

I am using a psgi.streaming callback to stream some files from the server.

I know the Content Length and want to set this header.

However if I use certain plugins, anything that uses some post processing removes the Content Length (it's in to Plack::Util::response_callback )

This makes sense, but in this case it is doing the wrong thing.

The plugin I'm using is Plack::Middleware::ServerStatus::Lite and it doesn't alter the response at all, it just counts the bytes.  So it would be nice if this could leave my header intact.

I'm not sure if this is a bug on ServerStatus, on Plack::Util, a change request, or just me being stupid.

Can anyone help me out?


One workaround I have found is to set X-Content-Length and then create another middleware to run after ServerStatus and reset the header.  I think that will be ok, but seems like a hack :(

Regards,

Mike






Tatsuhiko Miyagawa

unread,
Dec 21, 2012, 11:57:15 AM12/21/12
to psgi-...@googlegroups.com
On Sat, Dec 22, 2012 at 1:52 AM, <fluff...@googlemail.com> wrote:
> I'm not sure if this is a bug on ServerStatus, on Plack::Util, a change
> request, or just me being stupid.

Your observation is correct and I'd say it's not a bug of any of those
- they all do the right thing. response_cb eliminates Content-Length
when it's given a content filter sub because it might change the
length of the body and sending the original Content-Length will surely
break the clients if the filter rewrites it.

I'd advice not to use the streaming response but instead supply
filehandle or the whole body in an array or otherwise not use
ServerStatus, or stick with the workaround you just found.



--
Tatsuhiko Miyagawa

fluff...@googlemail.com

unread,
Dec 24, 2012, 7:05:37 AM12/24/12
to psgi-...@googlegroups.com

Thanks Tatsuhiko,  I'll do that, cheers!
Reply all
Reply to author
Forward
0 new messages