mikehale-rat-hole 0.1.4 → 0.1.5
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/History.txt +4 -0
- data/lib/rat_hole.rb +5 -4
- data/lib/util.rb +0 -1
- data/rat-hole.gemspec +1 -1
- data/test/test_rat_hole.rb +14 -4
- metadata +1 -1
data/History.txt
CHANGED
data/lib/rat_hole.rb
CHANGED
@@ -6,7 +6,7 @@ require 'util'
|
|
6
6
|
|
7
7
|
class RatHole
|
8
8
|
|
9
|
-
VERSION = '0.1.
|
9
|
+
VERSION = '0.1.5'
|
10
10
|
|
11
11
|
def initialize(host)
|
12
12
|
@host = host
|
@@ -22,16 +22,17 @@ class RatHole
|
|
22
22
|
|
23
23
|
def call(env)
|
24
24
|
Net::HTTP.start(@host) do |http|
|
25
|
-
http.instance_eval{@socket = MethodSpy.new(@socket){|method| method =~ /
|
25
|
+
http.instance_eval{@socket = MethodSpy.new(@socket){|method| method =~ /#{ENV['RH_METHOD_SPY_FILTER']}/}} if $DEBUG
|
26
26
|
|
27
27
|
env.delete('HTTP_ACCEPT_ENCODING')
|
28
28
|
source_request = process_user_request(Rack::Request.new(env))
|
29
29
|
source_headers = request_headers(source_request.env)
|
30
|
+
request_uri = "#{source_request.path_info}?#{source_request.query_string}"
|
30
31
|
|
31
32
|
if source_request.get?
|
32
|
-
response = http.get(
|
33
|
+
response = http.get(request_uri, source_headers)
|
33
34
|
elsif source_request.post?
|
34
|
-
post = Net::HTTP::Post.new(
|
35
|
+
post = Net::HTTP::Post.new(request_uri, source_headers)
|
35
36
|
class << post
|
36
37
|
include HTTPHeaderPatch
|
37
38
|
end
|
data/lib/util.rb
CHANGED
data/rat-hole.gemspec
CHANGED
data/test/test_rat_hole.rb
CHANGED
@@ -54,15 +54,15 @@ class TestRatHole < Test::Unit::TestCase
|
|
54
54
|
MockRequest.new(@io.written)
|
55
55
|
end
|
56
56
|
|
57
|
-
def send_get_request(rack_env={})
|
57
|
+
def send_get_request(rack_env={}, uri='/someuri')
|
58
58
|
opts = {:lint=>true}.merge(rack_env)
|
59
59
|
rh = RatHole.new('127.0.0.1')
|
60
|
-
Rack::MockRequest.new(rh).get(
|
60
|
+
Rack::MockRequest.new(rh).get(uri, opts)
|
61
61
|
end
|
62
62
|
|
63
|
-
def send_post_request(body='')
|
63
|
+
def send_post_request(body='', uri='/someuri')
|
64
64
|
rh = RatHole.new('127.0.0.1')
|
65
|
-
Rack::MockRequest.new(rh).post(
|
65
|
+
Rack::MockRequest.new(rh).post(uri, {:lint=>true, :input=> body})
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_response_unchanged
|
@@ -160,6 +160,16 @@ class TestRatHole < Test::Unit::TestCase
|
|
160
160
|
assert_equal(expected_headers, proxied_request.headers)
|
161
161
|
end
|
162
162
|
|
163
|
+
def test_request_uri
|
164
|
+
mock_server
|
165
|
+
send_get_request({}, '/uri?with=param')
|
166
|
+
assert_equal('/uri?with=param', proxied_request.uri)
|
167
|
+
|
168
|
+
mock_server
|
169
|
+
send_post_request('', '/uri?with=param')
|
170
|
+
assert_equal('/uri?with=param', proxied_request.uri)
|
171
|
+
end
|
172
|
+
|
163
173
|
def test_systemic_empty_rathole
|
164
174
|
host = 'halethegeek.com'
|
165
175
|
app = EmptyRatHole.new(host)
|