about summary refs log tree commit
path: root/lib/metropolis/input_wrapper.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-11-30 16:26:20 -0800
committerEric Wong <normalperson@yhbt.net>2010-11-30 16:26:20 -0800
commit27eb2d7ebd29239a5043a528c97c6dd218d03217 (patch)
tree7eb9ccc289cd78af10374c01fb80061f0abeeff3 /lib/metropolis/input_wrapper.rb
parent03755186d6cb968d44d7eb04de3ed2d047180272 (diff)
downloadmetropolis-27eb2d7ebd29239a5043a528c97c6dd218d03217.tar.gz
support pass-through :encoding for deflate and gzip
These allow serving pre-compressed data off disk and
on-the-fly uncompressing for the few clients that do
not accept compressed responses.
Diffstat (limited to 'lib/metropolis/input_wrapper.rb')
-rw-r--r--lib/metropolis/input_wrapper.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/metropolis/input_wrapper.rb b/lib/metropolis/input_wrapper.rb
new file mode 100644
index 0000000..12a1bcc
--- /dev/null
+++ b/lib/metropolis/input_wrapper.rb
@@ -0,0 +1,21 @@
+# -*- encoding: binary -*-
+
+class Metropolis::InputWrapper
+  def initialize(env)
+    @input = env["rack.input"]
+    env["rack.input"] = self
+  end
+
+  def read(*args)
+    args.empty? and return read_all
+    ni
+  end
+
+  def ni(*args)
+    raise NotImplementedError
+  end
+
+  alias gets ni
+  alias each ni
+  alias rewind ni
+end