forked from rack/rack
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
darcs-hash:20070301185301-4fc50-159ee23dc4ab0c209dcbf8d7e014a308d72434d7.gz
- Loading branch information
1 parent
9181a58
commit 376fa1e
Showing
15 changed files
with
211 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,62 @@ | ||
require 'zlib' | ||
|
||
# Paste has a Pony, Rack has a Lobster! | ||
|
||
module Rack | ||
LobsterString = Zlib::Inflate.inflate("eJx9kEEOwyAMBO99xd7MAcytUhPlJyj2 | ||
P6jy9i4k9EQyGAnBarEXeCBqSkntNXsi/ZCvC48zGQoZKikGrFMZvgS5ZHd+aGWVuWwhVF0 | ||
t1drVmiR42HcWNz5w3QanT+2gIvTVCiE1lm1Y0eU4JGmIIbaKwextKn8rvW+p5PIwFl8ZWJ | ||
I8jyiTlhTcYXkekJAzTyYN6E08A+dk8voBkAVTJQ==".delete("\n ").unpack("m*")[0]) | ||
# Paste has a Pony, Rack has a Lobster! | ||
class Lobster | ||
LobsterString = Zlib::Inflate.inflate("eJx9kEEOwyAMBO99xd7MAcytUhPlJyj2 | ||
P6jy9i4k9EQyGAnBarEXeCBqSkntNXsi/ZCvC48zGQoZKikGrFMZvgS5ZHd+aGWVuWwhVF0 | ||
t1drVmiR42HcWNz5w3QanT+2gIvTVCiE1lm1Y0eU4JGmIIbaKwextKn8rvW+p5PIwFl8ZWJ | ||
I8jyiTlhTcYXkekJAzTyYN6E08A+dk8voBkAVTJQ==".delete("\n ").unpack("m*")[0]) | ||
|
||
Lobster = lambda { |env| | ||
if env["QUERY_STRING"].include?("flip") | ||
lobster = LobsterString.split("\n"). | ||
map { |line| line.ljust(42).reverse }. | ||
join("\n") | ||
href = "?" | ||
else | ||
lobster = LobsterString | ||
href = "?flip" | ||
LambdaLobster = lambda { |env| | ||
if env["QUERY_STRING"].include?("flip") | ||
lobster = LobsterString.split("\n"). | ||
map { |line| line.ljust(42).reverse }. | ||
join("\n") | ||
href = "?" | ||
else | ||
lobster = LobsterString | ||
href = "?flip" | ||
end | ||
|
||
[200, {"Content-Type" => "text/html"}, | ||
["<title>Lobstericious!</title>", | ||
"<pre>", lobster, "</pre>", | ||
"<a href='#{href}'>flip!</a>"] | ||
] | ||
} | ||
|
||
def call(env) | ||
req = Request.new(env) | ||
if req.GET["flip"] == "left" | ||
lobster = LobsterString.split("\n"). | ||
map { |line| line.ljust(42).reverse }. | ||
join("\n") | ||
href = "?flip=right" | ||
elsif req.GET["flip"] == "crash" | ||
raise "Lobster crashed" | ||
else | ||
lobster = LobsterString | ||
href = "?flip=left" | ||
end | ||
|
||
Response.new.finish do |res| | ||
res.write "<title>Lobstericious!</title>" | ||
res.write "<pre>" | ||
res.write lobster | ||
res.write "</pre>" | ||
res.write "<p><a href='#{href}'>flip!</a></p>" | ||
res.write "<p><a href='?flip=crash'>crash!</a></p>" | ||
end | ||
end | ||
|
||
[200, {"Content-Type" => "text/html"}, | ||
["<title>Lobstericious!</title>", | ||
"<pre>", lobster, "</pre>", | ||
"<a href='#{href}'>flip!</a>"] | ||
] | ||
} | ||
|
||
Lobster2 = lambda { |env| | ||
req = Request.new(env) | ||
if req.GET["flip"] == "left" | ||
lobster = LobsterString.split("\n"). | ||
map { |line| line.ljust(42).reverse }. | ||
join("\n") | ||
href = "?flip=right" | ||
elsif req.GET["flip"] == "crash" | ||
raise "Lobster crashed" | ||
else | ||
lobster = LobsterString | ||
href = "?flip=left" | ||
end | ||
|
||
Response.new.finish do |res| | ||
res.write "<title>Lobstericious!</title>" | ||
res.write "<pre>" | ||
res.write lobster | ||
res.write "</pre>" | ||
res.write "<p><a href='#{href}'>flip!</a></p>" | ||
res.write "<p><a href='?flip=crash'>crash!</a></p>" | ||
end | ||
} | ||
end | ||
end | ||
|
||
if $0 == __FILE__ | ||
require 'rack' | ||
require 'rack/showexceptions' | ||
Rack::Handler::WEBrick.run \ | ||
Rack::ShowExceptions.new(Rack::Lint.new(Rack::Lobster2)), | ||
Rack::ShowExceptions.new(Rack::Lint.new(Rack::Lobster.new)), | ||
:Port => 9202 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.