From bee04061f47b689043880b66cff24bb9a7c63fa3 Mon Sep 17 00:00:00 2001 From: vinnyglennon Date: Sat, 7 Jan 2012 21:21:11 +0000 Subject: [PATCH 1/2] The Rack application on this page does not run on Ruby 1.9.2. The error is "Response body must respond to each". Ruby 1.9 (unlike 1.8) apparently doesn't provide an each method on string objects. A possible fix is to change the following line from this: [200, {"Content-Type" => "text/html"}, "Hello World! From Rsa Signature\n"] to this: [200, {"Content-Type" => "text/html"}, ["Hello World! From Rsa Signature\n"]] thus making the body string into an array of strings. --- chapter_10/public_private/config.ru | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter_10/public_private/config.ru b/chapter_10/public_private/config.ru index f9b0fe1..c73deb0 100644 --- a/chapter_10/public_private/config.ru +++ b/chapter_10/public_private/config.ru @@ -2,4 +2,4 @@ require 'rsa_sig_validator' use Rack::RsaSigValidator -run Proc.new { |env| [200, {"Content-Type" => "text/html"}, "Hello World! From Rsa Signature\n"] } +run Proc.new { |env| [200, {"Content-Type" => "text/html"}, ["Hello World! From Rsa Signature\n"]] } From 1c529a9dadb75a00a8e6c8b269627ae3260ae859 Mon Sep 17 00:00:00 2001 From: vinnyglennon Date: Sat, 7 Jan 2012 21:22:46 +0000 Subject: [PATCH 2/2] The Rack application on this page does not run on Ruby 1.9.2. The error is "Response body must respond to each". Ruby 1.9 (unlike 1.8) apparently doesn't provide an each method on string objects. A possible fix is to change the following line from this: [200, {}, "output"] to this: [200, {}, ["output"]] thus making the body string into an array of strings. --- chapter_10/public_private/rsa_sig_validator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter_10/public_private/rsa_sig_validator.rb b/chapter_10/public_private/rsa_sig_validator.rb index 63b6c9a..8fd62f4 100644 --- a/chapter_10/public_private/rsa_sig_validator.rb +++ b/chapter_10/public_private/rsa_sig_validator.rb @@ -13,7 +13,7 @@ def call(env) if signature_is_valid?(env) @app.call(env) else - [401, {"Content-Type" => "text/html"}, "Bad Signature"] + [401, {"Content-Type" => "text/html"}, ["Bad Signature"]] end end