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.
@@ -1,3 +1,7 @@
1
+ === 0.1.5 / 2008-12-18
2
+
3
+ * calculate request_uri = path_info + query_string
4
+
1
5
  === 0.1.4 / 2008-12-18
2
6
 
3
7
  * update process_server_response hook to include rack_request
@@ -6,7 +6,7 @@ require 'util'
6
6
 
7
7
  class RatHole
8
8
 
9
- VERSION = '0.1.4'
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 =~ /write/}} if $DEBUG
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(source_request.path_info, source_headers)
33
+ response = http.get(request_uri, source_headers)
33
34
  elsif source_request.post?
34
- post = Net::HTTP::Post.new(source_request.path_info, source_headers)
35
+ post = Net::HTTP::Post.new(request_uri, source_headers)
35
36
  class << post
36
37
  include HTTPHeaderPatch
37
38
  end
@@ -21,7 +21,6 @@ class MethodSpy
21
21
 
22
22
  def method_missing(symbol, *args, &block)
23
23
  result = @delegate.send(symbol, *args, &block)
24
- @block.call if @block
25
24
  p [symbol, args, result, block] if @filter && @filter.call(symbol.to_s)
26
25
  result
27
26
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{rat-hole}
3
- s.version = "0.1.4"
3
+ s.version = "0.1.5"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Michael Hale", "David Bogus"]
@@ -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('/someuri', opts)
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('/someuri', {:lint=>true, :input=> body})
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mikehale-rat-hole
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hale