lighttpd_pathinfo_fix 1.0.1 → 1.0.2
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/lib/lighttpd_pathinfo_fix.rb +20 -3
- data/test/test_lighttpd_pathinfo_fix.rb +22 -0
- metadata +7 -5
@@ -3,15 +3,23 @@
|
|
3
3
|
# This middleware fixes this issue. This is also
|
4
4
|
# modified to account for the case when SCRIPT_NAME is the name of the 404 script
|
5
5
|
class LighttpdPathinfoFix
|
6
|
-
VERSION = '1.0.
|
6
|
+
VERSION = '1.0.2'
|
7
|
+
DBG = 'DEBUG_LIGHTTPD_PATH_INFO_FIX'
|
7
8
|
|
8
9
|
def initialize(app)
|
9
10
|
@app = app
|
10
11
|
end
|
11
12
|
|
12
13
|
def call(env)
|
13
|
-
|
14
|
-
|
14
|
+
unless env["SERVER_SOFTWARE"].to_s =~ /lightt/i
|
15
|
+
inform("Skipping lighttpd pathinfo fix this since this is not a Lighttpd install")
|
16
|
+
return @app.call(env)
|
17
|
+
end
|
18
|
+
|
19
|
+
unless env["PATH_INFO"].to_s.empty?
|
20
|
+
inform("Skipping lighttpd pathinfo fix - PATH_INFO was #{env["PATH_INFO"]}")
|
21
|
+
return @app.call(env)
|
22
|
+
end
|
15
23
|
|
16
24
|
# Retreive the actual URI
|
17
25
|
uri, qs = env["REQUEST_URI"].to_s.split('?')
|
@@ -19,7 +27,16 @@ class LighttpdPathinfoFix
|
|
19
27
|
# Ensure URI has a leading slash
|
20
28
|
uri = "/#{uri}" unless uri =~ /^\//
|
21
29
|
munged_env = env.merge("PATH_INFO" => uri, "QUERY_STRING" => qs, "SCRIPT_NAME" => "")
|
30
|
+
inform("Munged PATH_INFO to be #{uri}")
|
22
31
|
|
23
32
|
@app.call(munged_env)
|
24
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def inform(msg)
|
38
|
+
if ENV[DBG]
|
39
|
+
File.open("/tmp/lighttpd_pathinfo_fix.log", "w") {|f| f.write(msg) }
|
40
|
+
end
|
41
|
+
end
|
25
42
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "test/unit"
|
2
|
+
require "stringio"
|
2
3
|
require "lighttpd_pathinfo_fix"
|
3
4
|
require "flexmock"
|
4
5
|
require "flexmock/test_unit"
|
@@ -73,4 +74,25 @@ class TestLighttpdPathinfoFix < Test::Unit::TestCase
|
|
73
74
|
@fix.call(source)
|
74
75
|
end
|
75
76
|
|
77
|
+
def test_writes_to_logfile
|
78
|
+
debug_var = 'DEBUG_LIGHTTPD_PATH_INFO_FIX'
|
79
|
+
# FINISH ME
|
80
|
+
flunk
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_root_path_properly_munged_even_without_fcgi_role
|
84
|
+
source = {"SERVER_SOFTWARE"=>"lighttpd/1.4.19",
|
85
|
+
"SCRIPT_NAME"=>"/config.ru", "PATH_INFO"=>"",
|
86
|
+
"SCRIPT_FILENAME"=>"/Code/apps/flame_bacula_search/config.ru",
|
87
|
+
"DOCUMENT_ROOT"=>"/Code/apps/flame_bacula_search",
|
88
|
+
"REQUEST_URI"=>"/?foo=bar", "REDIRECT_URI"=>"/config.ru", "QUERY_STRING"=>"", "REQUEST_PATH"=>"/"}
|
89
|
+
dest = {"SERVER_SOFTWARE"=>"lighttpd/1.4.19",
|
90
|
+
"SCRIPT_NAME"=>"", "PATH_INFO"=>"/", "SCRIPT_FILENAME"=>"/Code/apps/flame_bacula_search/config.ru",
|
91
|
+
"DOCUMENT_ROOT"=>"/Code/apps/flame_bacula_search", "REQUEST_URI"=>"/?foo=bar",
|
92
|
+
"REDIRECT_URI"=>"/config.ru", "QUERY_STRING"=>"foo=bar", "REQUEST_PATH"=>"/"}
|
93
|
+
|
94
|
+
@app.should_receive(:call).with(dest).once
|
95
|
+
@fix.call(source)
|
96
|
+
end
|
97
|
+
|
76
98
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: lighttpd_pathinfo_fix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Julik Tarkhanov
|
@@ -10,7 +10,8 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-18 00:00:00 +02:00
|
14
|
+
default_executable:
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: flexmock
|
@@ -29,9 +30,9 @@ dependencies:
|
|
29
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
30
31
|
none: false
|
31
32
|
requirements:
|
32
|
-
- -
|
33
|
+
- - ~>
|
33
34
|
- !ruby/object:Gem::Version
|
34
|
-
version: 2.
|
35
|
+
version: "2.10"
|
35
36
|
type: :development
|
36
37
|
version_requirements: *id002
|
37
38
|
description: |-
|
@@ -57,6 +58,7 @@ files:
|
|
57
58
|
- lib/lighttpd_pathinfo_fix.rb
|
58
59
|
- test/test_lighttpd_pathinfo_fix.rb
|
59
60
|
- .gemtest
|
61
|
+
has_rdoc: true
|
60
62
|
homepage: http://github.com/julik/lighttpd_pathinfo_fix
|
61
63
|
licenses: []
|
62
64
|
|
@@ -81,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
83
|
requirements: []
|
82
84
|
|
83
85
|
rubyforge_project: lighttpd_pathinfo_fix
|
84
|
-
rubygems_version: 1.
|
86
|
+
rubygems_version: 1.6.2
|
85
87
|
signing_key:
|
86
88
|
specification_version: 3
|
87
89
|
summary: This middleware fixes the lighttpd PATH_INFO for apps mounted at / in a way that is compatible with everything
|