OK, I just had a look to the passenger code and this is insane.
I think the problem is that we return the content-length as an int, but
passenger chokes if it gets anything except a string.
Can you try this (untested) patch:
diff --git a/lib/puppet/network/http/rack/rest.rb b/lib/puppet/network/http/rack/rest.rb
index e5f50c4..b7e1d97 100644
--- a/lib/puppet/network/http/rack/rest.rb
+++ b/lib/puppet/network/http/rack/rest.rb
@@ -41,7 +41,7 @@ class Puppet::Network::HTTP::RackREST < Puppet::Network::HTTP::RackHttpHandler
unless result.is_a?(File)
response.write result
else
- response["Content-Length"] = result.stat.size
+ response["Content-Length"] = result.stat.size.to_s
response.body = RackFile.new(result)
end
end
Let me know if that fixes the problem,
--
Brice Figureau
Follow the latest Puppet Community evolutions on www.planetpuppet.org!
If that doesn't pan out could the problem be with our format_to_mime
(i.e. the content type, rather than the content length)? That seems
equally odd, but it would explain why there isn't widespread
discussion of the problem (which I would expect if passenger were
requiring content length to be an string)--if we're somehow returning
an integer for the Content-Type it would be a problem that only we
would see.
-- Markus
-----------------------------------------------------------
The power of accurate observation is
commonly called cynicism by those
who have not got it. ~George Bernard Shaw
------------------------------------------------------------
This returns format.mime (format being the current renderer), which I
hope is a string or we'll have some troubles :-)
> That seems equally odd, but it would explain why there isn't widespread
> discussion of the problem (which I would expect if passenger were
> requiring content length to be an string)--if we're somehow returning
> an integer for the Content-Type it would be a problem that only we
> would see.
I suppose people don't use content-length with passenger (ie they user
chunk enconding), or they sanitize their headers to be strings.
And I think most if not all users don't set content-length themselves,
they just do: response.write(body), and rack does:
s = str.to_s
@length += Rack::Utils.bytesize(s)
@writer.call s
header["Content-Length"] = @length.to_s
(notice the to_s).
Except, we are streaming the file (with the rack's help) so we have to
set the content-length ourselves.
We indeed set content-length as an int (ie file.stat.size), and reading
passenger rack code:
headers.each do |key, values|
if values.is_a?(String)
values = values.split("\n")
end
values.each do |value|
output.write("#{key}: #{value}#{CRLF}")
end
end
Which is coherent with the error message. If we ask users the size of
the file it chokes on, I'm sure will find that it matches the fixnum we
find in the exception.
This just means I should setup a passenger setup (I was testing our rack
support with jruby/jetty-rackup and mongrel/rackup) as it differs from
other rack consumer :(
Agreed on almost everything with one niggling doubt.
> Which is coherent with the error message. If we ask users the size of
> the file it chokes on, I'm sure will find that it matches the fixnum we
> find in the exception.
You are probably correct but it looks as if the error message:
> This is the data that it sent: [Content-Type]
> *** Exception NoMethodError in
> PhusionPassenger::Rack::ApplicationSpawner (undefined method `each'
> for 1268:Fixnum) (process 28465):
...is referring to content type (which could just be the last thing it
processed successfully) and not to content length.
Still, if I had to bet I'd say that you're more likely to be correct.
This is the data that it sent: [Content-Type]
*** Exception NoMethodError in
PhusionPassenger::Rack::ApplicationSpawner (undefined method `each'
for 1268:Fixnum) (process 28465):
Which is coherent with the error message. If we ask users the size of
the file it chokes on, I'm sure will find that it matches the fixnum we
find in the exception.