webrick_httpreverseproxyserver 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -105,7 +105,7 @@ module WEBrick
105
105
  protected
106
106
  # find the *first* matching pattern in the proxy map
107
107
  def first_matching_proxy_rule(request)
108
- matching_rul = @config[:ProxyRules].detect { |rule|
108
+ matching_rule = @config[:ProxyRules].detect { |rule|
109
109
  re = Regexp.new(rule.pattern)
110
110
  m = re.match(request.path)
111
111
  not m.nil?
@@ -120,15 +120,16 @@ module WEBrick
120
120
  header = {}
121
121
  request.header.keys { |key| header[key] = request.header[key][0] }
122
122
  header['x-forwarded-for'] = request.peeraddr[2] # the name of the requesting host
123
- # send the new request to the private server (hacked from WEBrick::HTTPProxyServer)
124
- response = nil
123
+ # send the new request to the private server (hacked from
124
+ # WEBrick::HTTPProxyServer)
125
+ net_reponse = nil
125
126
  begin
126
127
  http = Net::HTTP.new(host, port)
127
128
  http.start {
128
129
  case request.request_method
129
- when "GET" then response = http.get(path, header)
130
- when "POST" then response = http.post(path, request.body || "", header)
131
- when "HEAD" then response = http.head(path, header)
130
+ when "GET" then net_reponse = http.get(path, header)
131
+ when "POST" then net_reponse = http.post(path, request.body || "", header)
132
+ when "HEAD" then net_reponse = http.head(path, header)
132
133
  else
133
134
  raise HTTPStatus::MethodNotAllowed,
134
135
  "unsupported method `#{request.request_method}'."
@@ -141,9 +142,9 @@ module WEBrick
141
142
  response['connection'] = "close"
142
143
 
143
144
  # Convert Net::HTTP::HTTPResponse to WEBrick::HTTPResponse
144
- response.status = response.code.to_i
145
- response.each { |key, val| response[key] = val }
146
- response.body = response.body
145
+ response.status = net_reponse.code.to_i
146
+ net_reponse.each { |key, val| response[key] = val }
147
+ response.body = net_reponse.body
147
148
 
148
149
  # Process contents
149
150
  if handler = @config[:ProxyContentHandler]
@@ -1,5 +1,5 @@
1
1
  module WEBrick
2
2
  class HTTPReverseProxyServer
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webrick_httpreverseproxyserver
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 31
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 1
9
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Richard Kernahan
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-07-22 00:00:00 +02:00
19
+ date: 2010-09-27 00:00:00 +02:00
19
20
  default_executable:
20
21
  dependencies: []
21
22
 
@@ -42,23 +43,27 @@ rdoc_options: []
42
43
  require_paths:
43
44
  - lib
44
45
  required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
45
47
  requirements:
46
48
  - - ">="
47
49
  - !ruby/object:Gem::Version
50
+ hash: 3
48
51
  segments:
49
52
  - 0
50
53
  version: "0"
51
54
  required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
52
56
  requirements:
53
57
  - - ">="
54
58
  - !ruby/object:Gem::Version
59
+ hash: 3
55
60
  segments:
56
61
  - 0
57
62
  version: "0"
58
63
  requirements: []
59
64
 
60
65
  rubyforge_project: "[none]"
61
- rubygems_version: 1.3.6
66
+ rubygems_version: 1.3.7
62
67
  signing_key:
63
68
  specification_version: 3
64
69
  summary: Implements a simple reverse HTTP proxy server