Skip to content

Commit

Permalink
Do not #force_encoding if it's not available
Browse files Browse the repository at this point in the history
  • Loading branch information
ixti committed Apr 6, 2014
1 parent 4c5d4e9 commit 1bd6430
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion spec/support/my_rack_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def self.call(env)
when ['GET', '/locked']
[200, {}, ["Single threaded response."]]
when ['POST', '/greet']
name = env["rack.input"].read(env["CONTENT_LENGTH"]).force_encoding("UTF-8")[/name=([^&]*)/, 1] || "World"
name = env["rack.input"].read(env["CONTENT_LENGTH"])
name = name.force_encoding("UTF-8") if name.respond_to? :force_encoding
name = name[/name=([^&]*)/, 1] || "World"
[200, {}, ["Good to meet you, #{name}!"]]
when ['GET', '/compute']
if env['SERVER_PORT'] == 80 && env["SCRIPT_NAME"] == ""
Expand Down

0 comments on commit 1bd6430

Please sign in to comment.