Ticket #129 (closed defect: wontfix)

Opened 19 months ago

Last modified 14 months ago

X-Sendfile returns "file not found" with Camping/Mongrel/Win32

Reported by: undees Owned by: somebody
Priority: minor Milestone:
Component: camping.rb Version: 1.5
Keywords: X-Sendfile Mongrel Cc:

Description

I had a working WEBrick-based Camping app which used X-Sendfile for its static CSS and image resources. I installed Junebug Wiki for unrelated reasons. Junebug requires Mongrel, which means that my own Camping app has suddenly started using Mongrel by default.

Now, all of my static resources return the text "file not found" with no explanation given.

When I launch my app with "camping --server webrick myapp.rb", static files work fine. I'll continue to use this workaround for my own app, but that doesn't help Junebug -- it requires Mongrel.

I'm on Win32, btw.

Change History

follow-up: ↓ 4   Changed 15 months ago by zimbatm

There is a bug in Mongrel's camping handler. The code is not bundled with Camping, but with Mongrel, so a bug has been added to it's bug tracker.

--- camping.rb.orig	2007-09-17 23:41:58.000000000 +0200
+++ camping.rb	2007-09-17 23:42:04.000000000 +0200
@@ -38,7 +38,7 @@
       @@file_only_methods = ["GET","HEAD"]
 
       def initialize(klass)
-        @files = Mongrel::DirHandler.new("/",false)
+        @files = Mongrel::DirHandler.new(".",false)
         @guard = Mutex.new
         @klass = klass
       end

  Changed 15 months ago by zimbatm

  • status changed from new to closed
  • resolution set to wontfix

Damned, this doesn't work if Camping is not launched in the same path as the application.

The final answer is : X-Sendfile should always use absolute paths.

  Changed 15 months ago by zimbatm

in reply to: ↑ 1   Changed 14 months ago by mitchecu

Here is a fix that worked for me. It is a fix to the Camping.rb file in the Mongrel project. I haven't posted it on the Mongrel site because it isn't exactly backward compatible, which may be an issue for people not on Win32. I hope it helps.

--- camping.rb.orig      2007-10-04 20:36:01.000000000 -0400
+++ camping.rb    2007-10-04 21:31:42.000000000 -0400
@@ -38,7 +38,7 @@
       @@file_only_methods = ["GET","HEAD"]
 
       def initialize(klass)
-        @files = Mongrel::DirHandler.new("/",false)
+        @files = Mongrel::DirHandler.new(File.dirname(klass.instance_eval{@script}),false)
         @guard = Mutex.new
         @klass = klass
       end
Note: See TracTickets for help on using tickets.