DefV-rack_lighttpd_fix 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +31 -0
- data/lib/rack/lighttpd_fix.rb +12 -0
- data/test/test_lighttpd_fix.rb +25 -0
- metadata +55 -0
data/README.rdoc
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
= Rack::LighttpdFix
|
2
|
+
|
3
|
+
== Why?
|
4
|
+
|
5
|
+
On some of the Openminds shared hosting servers we run a Lighttpd+FCGI stack for Ruby/Rails applications. This week we got a complaint from a user saying they had a problem with the latest Radiant 0.8. Every page he loaded was the same as the first page he opened since the last server restart.
|
6
|
+
|
7
|
+
When digging into the problem it was clear that it was a problem with Rack::Cache, which only created 1 meta-store entry and served that from there on. On investigation Rack::Cache::Key.call(@request) always returned http://example.com:80/dispatch.fcgi?. Apparently the last part of the key gets created by scriptname and pathinfo:
|
8
|
+
|
9
|
+
..snip..
|
10
|
+
parts << @request.script_name
|
11
|
+
parts << @request.path_info
|
12
|
+
..snip..
|
13
|
+
|
14
|
+
When looking at the request it seems Lighttpd+FCGI doesn't fill in the env['PATH_INFO�], which results in always having the same cache key, thus the same page.
|
15
|
+
|
16
|
+
To solve this problem I've created this small Rack middleware gem that sets PATH_INFO from REQUEST_URI (Like Passenger does with Nginx)
|
17
|
+
|
18
|
+
== Installation
|
19
|
+
|
20
|
+
You can just install this as a gem:
|
21
|
+
gem install -s http://gems.github.com defv-rack_lighttpd_fix
|
22
|
+
|
23
|
+
== Configuration for Rails
|
24
|
+
|
25
|
+
# in production.rb
|
26
|
+
require 'rack/lighttpd_fix'
|
27
|
+
|
28
|
+
config.middleware.insert_before ::Rack::Cache, ::Rack::LighttpdFix
|
29
|
+
|
30
|
+
# or for Radiant
|
31
|
+
config.middleware.insert_before ::Radiant::Cache, ::Rack::LighttpdFix
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "rack/lighttpd_fix"
|
2
|
+
|
3
|
+
class TestLibraryFileName < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, "Hello, World!"] }
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_root_request
|
9
|
+
env = {
|
10
|
+
'REQUEST_URI' => '/'
|
11
|
+
}
|
12
|
+
|
13
|
+
response = Rack::LighttpdFix.new(@app).call(env)
|
14
|
+
assert_equal '/', env['PATH_INFO']
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_request_with_GET_params
|
18
|
+
env = {
|
19
|
+
'REQUEST_URI' => '/foo?bar=1'
|
20
|
+
}
|
21
|
+
|
22
|
+
response = Rack::LighttpdFix.new(@app).call(env)
|
23
|
+
assert_equal '/foo', env['PATH_INFO']
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: DefV-rack_lighttpd_fix
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan De Poorter (Openminds)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-17 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Rack::Cache uses PATH_INFO to calculate the cache-url. Lighttpd sets this wrong. This Rack middleware fixes that
|
17
|
+
email: code@openminds.be
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- README.rdoc
|
26
|
+
- lib/rack/lighttpd_fix.rb
|
27
|
+
- test/test_lighttpd_fix.rb
|
28
|
+
has_rdoc: false
|
29
|
+
homepage: http://github.com/DefV/rack_lighttpd_fix/tree/master
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: "0"
|
40
|
+
version:
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
version:
|
47
|
+
requirements: []
|
48
|
+
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 1.2.0
|
51
|
+
signing_key:
|
52
|
+
specification_version: 2
|
53
|
+
summary: Lighttpd fix to set correct PATH_INFO
|
54
|
+
test_files: []
|
55
|
+
|