<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -5,30 +5,21 @@ require 'phuby'
 require 'rack'
 require 'rack/showexceptions'
 
-###
+##
 # Rack::Phrack is a Rack handler that will evaulate and serve PHP files.
-#
-# The handler creates a new PHP runtime if it detects that a PHP file has
-# been requested.
+
 class Rack::Phrack &lt; Rack::File
   class Events &lt; Struct.new(:code, :headers, :body)
-    def write string
-      body &lt;&lt; string
-    end
+    def write string; body &lt;&lt; string; end
+    def send_headers response_code;   end
 
     def header value, op
       k, v = value.split(': ', 2)
-      case k
-      when 'Location'
+      if k == 'Location' then
         self.code = 302
         v = Rack::Utils.unescape v
-      when 'Set-Cookie'
-        v = [headers[k], v].compact.join &quot;\n&quot;
       end
-      headers[k] = v
-    end
-
-    def send_headers response_code
+      headers[k] = [headers[k], v].compact.join &quot;\n&quot;
     end
   end
 
@@ -41,40 +32,25 @@ class Rack::Phrack &lt; Rack::File
 
     Dir.chdir(File.dirname(file)) do
       Phuby::Runtime.php do |rt|
-        # Set the timezone. *shrug*
-        rt.eval &quot;date_default_timezone_set('America/Los_Angeles');&quot;
-
-        # Set the GET parameters in the PHP runtime
-        Rack::Utils.parse_query(env['QUERY_STRING']).each { |k,v|
-          rt[&quot;_GET&quot;][k] = v
-        }
+        rt.eval &quot;date_default_timezone_set('America/Los_Angeles');&quot; # *shrug*
 
-        # Set the POST parameters in the PHP runtime
-        Rack::Utils.parse_query(env['rack.input'].read).each { |k,v|
-          rt[&quot;_POST&quot;][k] = v
-        }
-
-        # Set the cookies in the PHP runtime
-        Rack::Utils.parse_query(env['HTTP_COOKIE'], ';').each { |k,v|
-          rt[&quot;_COOKIE&quot;][k] = v
-        }
+        { Rack::Utils.parse_query(env['QUERY_STRING'])     =&gt; &quot;_GET&quot;,
+          Rack::Utils.parse_query(env['rack.input'].read)  =&gt; &quot;_POST&quot;,
+          Rack::Utils.parse_query(env['HTTP_COOKIE'], ';') =&gt; &quot;_COOKIE&quot;,
+        }.each do |from, to|
+          from.each { |k,v| rt[to][k] = v }
+        end
 
-        # Set other misc info.
         env.each { |k,v| rt['_SERVER'][k] = v || '' unless k =~ /^rack/ }
         rt[&quot;_SERVER&quot;]['REQUEST_URI'] = env['PATH_INFO']
 
-        # Evaluate the PHP file
-        rt.with_events(events) do
-          File.open(file, 'rb') { |f| rt.eval f }
-        end
+        rt.with_events(events) { rt.eval File.read(file) } # RUN!
       end
     end
     events.to_a
   end
 end
 
-if $0 == __FILE__
-  Rack::Handler::WEBrick.run(
+Rack::Handler::WEBrick.run(
     Rack::ShowExceptions.new(Rack::Phrack.new(ARGV[0] || Dir.pwd)),
-    :Port =&gt; 10101)
-end
+    :Port =&gt; 10101) if $0 == __FILE__</diff>
      <filename>bin/phrack</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7052fc8fedf3ecce2f8dffd5577dacf6f203040f</id>
    </parent>
  </parents>
  <author>
    <name>Ryan Davis</name>
    <email>ryand-ruby@zenspider.com</email>
  </author>
  <url>http://github.com/tenderlove/phuby/commit/cb4d6d06dac3c1c82214efee96ffdee3cb2e9b21</url>
  <id>cb4d6d06dac3c1c82214efee96ffdee3cb2e9b21</id>
  <committed-date>2009-10-26T13:59:42-07:00</committed-date>
  <authored-date>2009-10-26T13:59:42-07:00</authored-date>
  <message>Less than 60 lines!</message>
  <tree>af48d3dfd483acf0fc4068bf4e5bc41d701ae0c3</tree>
  <committer>
    <name>Ryan Davis</name>
    <email>ryand-ruby@zenspider.com</email>
  </committer>
</commit>
