<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -15,14 +15,19 @@ module Rack
         env = ENV.to_hash
         env.delete &quot;HTTP_CONTENT_LENGTH&quot;
         env[&quot;SCRIPT_NAME&quot;] = &quot;&quot; if env[&quot;SCRIPT_NAME&quot;] == &quot;/&quot;
-        env.update({&quot;rack.version&quot; =&gt; [1,0],
-                     &quot;rack.input&quot; =&gt; StringIO.new($stdin.read.to_s),
-                     &quot;rack.errors&quot; =&gt; $stderr,
-                     &quot;rack.multithread&quot; =&gt; false,
-                     &quot;rack.multiprocess&quot; =&gt; true,
-                     &quot;rack.run_once&quot; =&gt; false,
-                     &quot;rack.url_scheme&quot; =&gt; [&quot;yes&quot;, &quot;on&quot;, &quot;1&quot;].include?(ENV[&quot;HTTPS&quot;]) ? &quot;https&quot; : &quot;http&quot;
-                   })
+
+        rack_input = RewindableInput.new($stdin.read.to_s)
+
+        env.update(
+          &quot;rack.version&quot; =&gt; [1,0],
+          &quot;rack.input&quot; =&gt; rack_input,
+          &quot;rack.errors&quot; =&gt; $stderr,
+          &quot;rack.multithread&quot; =&gt; false,
+          &quot;rack.multiprocess&quot; =&gt; true,
+          &quot;rack.run_once&quot; =&gt; false,
+          &quot;rack.url_scheme&quot; =&gt; [&quot;yes&quot;, &quot;on&quot;, &quot;1&quot;].include?(ENV[&quot;HTTPS&quot;]) ? &quot;https&quot; : &quot;http&quot;
+        )
+
         env[&quot;QUERY_STRING&quot;] ||= &quot;&quot;
         env[&quot;HTTP_VERSION&quot;] ||= env[&quot;SERVER_PROTOCOL&quot;]
         env[&quot;REQUEST_PATH&quot;] ||= &quot;/&quot;</diff>
      <filename>lib/rack/handler/lsws.rb</filename>
    </modified>
    <modified>
      <diff>@@ -45,6 +45,9 @@ module Rack
 
         env[&quot;SCRIPT_NAME&quot;] = &quot;&quot;  if env[&quot;SCRIPT_NAME&quot;] == &quot;/&quot;
 
+        rack_input = request.body || StringIO.new('')
+        rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding)
+
         env.update({&quot;rack.version&quot; =&gt; [1,0],
                      &quot;rack.input&quot; =&gt; request.body || StringIO.new(&quot;&quot;),
                      &quot;rack.errors&quot; =&gt; $stderr,</diff>
      <filename>lib/rack/handler/mongrel.rb</filename>
    </modified>
    <modified>
      <diff>@@ -32,10 +32,13 @@ module Rack
         env[&quot;PATH_INFO&quot;] = env[&quot;REQUEST_PATH&quot;]
         env[&quot;QUERY_STRING&quot;] ||= &quot;&quot;
         env[&quot;SCRIPT_NAME&quot;] = &quot;&quot;
+
+        rack_input = StringIO.new(input_body)
+        rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding)
+
         env.update({&quot;rack.version&quot; =&gt; [1,0],
-                     &quot;rack.input&quot; =&gt; StringIO.new(input_body),
+                     &quot;rack.input&quot; =&gt; rack_input,
                      &quot;rack.errors&quot; =&gt; $stderr,
-
                      &quot;rack.multithread&quot; =&gt; true,
                      &quot;rack.multiprocess&quot; =&gt; true,
                      &quot;rack.run_once&quot; =&gt; false,</diff>
      <filename>lib/rack/handler/scgi.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,8 +23,11 @@ module Rack
         env = req.meta_vars
         env.delete_if { |k, v| v.nil? }
 
+        rack_input = StringIO.new(req.body.to_s)
+        rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding)
+
         env.update({&quot;rack.version&quot; =&gt; [1,0],
-                     &quot;rack.input&quot; =&gt; StringIO.new(req.body.to_s),
+                     &quot;rack.input&quot; =&gt; rack_input,
                      &quot;rack.errors&quot; =&gt; $stderr,
 
                      &quot;rack.multithread&quot; =&gt; true,</diff>
      <filename>lib/rack/handler/webrick.rb</filename>
    </modified>
    <modified>
      <diff>@@ -116,11 +116,14 @@ module Rack
 
       opts[:input] ||= &quot;&quot;
       if String === opts[:input]
-        env[&quot;rack.input&quot;] = StringIO.new(opts[:input])
+        rack_input = StringIO.new(opts[:input])
       else
-        env[&quot;rack.input&quot;] = opts[:input]
+        rack_input = opts[:input]
       end
 
+      rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding)
+      env['rack.input'] = rack_input
+
       env[&quot;CONTENT_LENGTH&quot;] ||= env[&quot;rack.input&quot;].length.to_s
 
       opts.each { |field, value|</diff>
      <filename>lib/rack/mock.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>889d4d6c3186e2fffeea112a43f37766c6ccec19</id>
    </parent>
  </parents>
  <author>
    <name>Michael Fellinger</name>
    <email>m.fellinger@gmail.com</email>
  </author>
  <url>http://github.com/rack/rack/commit/4e53cc767057fd7d425f99e26b9f5131804096ef</url>
  <id>4e53cc767057fd7d425f99e26b9f5131804096ef</id>
  <committed-date>2009-06-30T03:53:38-07:00</committed-date>
  <authored-date>2009-06-30T03:53:38-07:00</authored-date>
  <message>Set correct external_encoding for handlers that don't use RewindableInput</message>
  <tree>0419018b25cded5ae8bc013415337e8b84d126dc</tree>
  <committer>
    <name>Michael Fellinger</name>
    <email>m.fellinger@gmail.com</email>
  </committer>
</commit>
