Skip to content

Commit 7995618

Browse files
committed
Trailing commas in calls are not possible in ruby 1.8
1 parent ae0224c commit 7995618

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

.rubocop.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ Style/StringLiterals:
44
Metrics/LineLength:
55
Max: 100
66

7-
Style/TrailingComma:
8-
EnforcedStyleForMultiline: comma
9-
107
#begin ruby 1.8 support
118
Style/HashSyntax:
129
EnforcedStyle: hash_rockets
1310

1411
Style/Lambda:
1512
Enabled: false
13+
14+
Style/TrailingComma:
15+
EnforcedStyleForMultiline: no_comma

lib/rack_reverse_proxy/middleware.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def initialize(app = nil, &b)
2121
:preserve_host => true,
2222
:x_forwarded_host => true,
2323
:matching => :all,
24-
:replace_response_host => false,
24+
:replace_response_host => false
2525
}
2626
instance_eval(&b) if block_given?
2727
end
@@ -31,7 +31,7 @@ def call(env)
3131
matcher = get_matcher(
3232
rackreq.fullpath,
3333
Rack::Proxy.extract_http_request_headers(rackreq.env),
34-
rackreq,
34+
rackreq
3535
)
3636
return @app.call(env) if matcher.nil?
3737

@@ -57,7 +57,7 @@ def proxy(env, source_request, matcher)
5757

5858
# Initialize request
5959
target_request = Net::HTTP.const_get(
60-
source_request.request_method.capitalize,
60+
source_request.request_method.capitalize
6161
).new(uri.request_uri)
6262

6363
# Setup headers
@@ -102,7 +102,7 @@ def proxy(env, source_request, matcher)
102102

103103
# Let rack set the transfer-encoding header
104104
response_headers = Rack::Utils::HeaderHash.new(
105-
Rack::Proxy.normalize_headers(format_headers(target_response.headers)),
105+
Rack::Proxy.normalize_headers(format_headers(target_response.headers))
106106
)
107107
response_headers.delete("Transfer-Encoding")
108108
response_headers.delete("Status")

rack-reverse-proxy.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ Gem::Specification.new do |spec|
1010
"Jon Swope",
1111
"Ian Ehlert",
1212
"Roman Ernst",
13-
"Oleksii Fedorov",
13+
"Oleksii Fedorov"
1414
]
1515

1616
spec.email = [
1717
1818
1919
20-
20+
2121
]
2222

2323
spec.summary = "A Simple Reverse Proxy for Rack"

spec/rack/reverse_proxy_spec.rb

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def dummy_app
1818
:verify_mode= => nil,
1919
:headers => {},
2020
:status => 200,
21-
:body => "OK",
21+
:body => "OK"
2222
)
2323
end
2424

@@ -50,7 +50,7 @@ def app
5050

5151
it "parses the headers as a Hash with values of type String" do
5252
stub_request(:get, "http://example.com/test").to_return(
53-
:headers => { "cache-control" => "max-age=300, public" },
53+
:headers => { "cache-control" => "max-age=300, public" }
5454
)
5555
get "/test"
5656
expect(last_response.headers["cache-control"]).to be_an_instance_of(String)
@@ -68,8 +68,8 @@ def app
6868
get "/test/stuff"
6969
expect(
7070
a_request(:get, "http://example.com/test/stuff").with(
71-
:headers => { "Host" => "example.com" },
72-
),
71+
:headers => { "Host" => "example.com" }
72+
)
7373
).to have_been_made
7474
end
7575

@@ -78,8 +78,8 @@ def app
7878
get "/test/stuff"
7979
expect(
8080
a_request(:get, "http://example.com/test/stuff").with(
81-
:headers => { "X-Forwarded-Host" => "example.org" },
82-
),
81+
:headers => { "X-Forwarded-Host" => "example.org" }
82+
)
8383
).to have_been_made
8484
end
8585

@@ -96,7 +96,7 @@ def app
9696

9797
it "formats the headers correctly to avoid duplicates" do
9898
stub_request(:get, "http://example.com/2test").to_return(
99-
:headers => { :date => "Wed, 22 Jul 2015 11:27:21 GMT" },
99+
:headers => { :date => "Wed, 22 Jul 2015 11:27:21 GMT" }
100100
)
101101

102102
get "/2test"
@@ -109,7 +109,7 @@ def app
109109
it "formats the headers with dashes correctly" do
110110
stub_request(:get, "http://example.com/2test").to_return(
111111
:status => 301,
112-
:headers => { :status => "301 Moved Permanently", :"x-additional-info" => "something" },
112+
:headers => { :status => "301 Moved Permanently", :"x-additional-info" => "something" }
113113
)
114114

115115
get "/2test"
@@ -131,8 +131,8 @@ def app
131131
get "/test/stuff"
132132
expect(
133133
a_request(:get, "http://example.com:8080/test/stuff").with(
134-
:headers => { "Host" => "example.com:8080" },
135-
),
134+
:headers => { "Host" => "example.com:8080" }
135+
)
136136
).to have_been_made
137137
end
138138
end
@@ -150,8 +150,8 @@ def app
150150

151151
expect(
152152
a_request(:get, "http://example.com/test/stuff").with(
153-
:headers => { "Host" => "example.com" },
154-
),
153+
:headers => { "Host" => "example.com" }
154+
)
155155
).not_to have_been_made
156156

157157
expect(a_request(:get, "http://example.com/test/stuff")).to have_been_made
@@ -171,8 +171,8 @@ def app
171171
get "/test/stuff"
172172
expect(
173173
a_request(:get, "http://example.com/test/stuff").with(
174-
:headers => { "X-Forwarded-Host" => "example.org" },
175-
),
174+
:headers => { "X-Forwarded-Host" => "example.org" }
175+
)
176176
).not_to have_been_made
177177
expect(a_request(:get, "http://example.com/test/stuff")).to have_been_made
178178
end
@@ -217,7 +217,7 @@ def app
217217

218218
it "makes request with basic auth" do
219219
stub_request(:get, "http://joe:[email protected]/test/stuff").to_return(
220-
:body => "secured content",
220+
:body => "secured content"
221221
)
222222
get "/test/stuff"
223223
expect(last_response.body).to eq("secured content")
@@ -233,15 +233,15 @@ def app
233233

234234
it "replaces the location response header" do
235235
stub_request(:get, "http://example.com/test/stuff").to_return(
236-
:headers => { "location" => "http://test.com/bar" },
236+
:headers => { "location" => "http://test.com/bar" }
237237
)
238238
get "http://example.com/test/stuff"
239239
expect(last_response.headers["location"]).to eq("http://example.com/bar")
240240
end
241241

242242
it "keeps the port of the location" do
243243
stub_request(:get, "http://example.com/test/stuff").to_return(
244-
:headers => { "location" => "http://test.com/bar" },
244+
:headers => { "location" => "http://test.com/bar" }
245245
)
246246
get "http://example.com:3000/test/stuff"
247247
expect(last_response.headers["location"]).to eq("http://example.com:3000/bar")
@@ -302,7 +302,7 @@ def app
302302

303303
it "makes a secure request" do
304304
stub_request(:get, "https://example.com/test/stuff").to_return(
305-
:body => "Proxied Secure App",
305+
:body => "Proxied Secure App"
306306
)
307307
get "/test/stuff"
308308
expect(last_response.body).to eq("Proxied Secure App")
@@ -313,8 +313,8 @@ def app
313313
get "/test/stuff"
314314
expect(
315315
a_request(:get, "https://example.com/test/stuff").with(
316-
:headers => { "Host" => "example.com" },
317-
),
316+
:headers => { "Host" => "example.com" }
317+
)
318318
).to have_been_made
319319
end
320320
end
@@ -331,8 +331,8 @@ def app
331331
get "/test/stuff"
332332
expect(
333333
a_request(:get, "https://example.com:8443/test/stuff").with(
334-
:headers => { "Host" => "example.com:8443" },
335-
),
334+
:headers => { "Host" => "example.com:8443" }
335+
)
336336
).to have_been_made
337337
end
338338
end
@@ -375,7 +375,7 @@ def app
375375
describe "and using method #{method}" do
376376
it "forwards the correct request" do
377377
stub_request(method.to_sym, "http://example.com/test").to_return(
378-
:body => "Proxied App for #{method}",
378+
:body => "Proxied App for #{method}"
379379
)
380380
send(method, "/test")
381381
expect(last_response.body).to eq("Proxied App for #{method}")
@@ -385,7 +385,7 @@ def app
385385
it "forwards the request payload" do
386386
stub_request(
387387
method.to_sym,
388-
"http://example.com/test",
388+
"http://example.com/test"
389389
).to_return { |req| { :body => req.body } }
390390
send(method, "/test", :test => "test")
391391
expect(last_response.body).to eq("test=test")
@@ -467,7 +467,7 @@ def app
467467

468468
it "proxies requests when a pattern is matched" do
469469
stub_request(:get, "http://users-example.com/users?user=omer").to_return(
470-
:body => "User App",
470+
:body => "User App"
471471
)
472472

473473
get "/test", :user => "mark"
@@ -500,15 +500,15 @@ def app
500500

501501
it "proxies requests when a pattern is matched and correct headers are passed" do
502502
stub_request(:get, "http://example.com/test").to_return(
503-
:body => "Proxied App with Headers",
503+
:body => "Proxied App with Headers"
504504
)
505505
get "/test", {}, "HTTP_ACCEPT" => "foo.bar"
506506
expect(last_response.body).to eq("Proxied App with Headers")
507507
end
508508

509509
it "does not proxy requests when a pattern is matched and incorrect headers are passed" do
510510
stub_request(:get, "http://example.com/test").to_return(
511-
:body => "Proxied App with Headers",
511+
:body => "Proxied App with Headers"
512512
)
513513
get "/test", {}, "HTTP_ACCEPT" => "bar.foo"
514514
expect(last_response.body).not_to eq("Proxied App with Headers")

0 commit comments

Comments
 (0)