<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,5 @@
 == 0.8.0 ??? release
+ * Serve static file only on GET and HEAD requests in Rails adapter, fixes #58
  * Add threaded option to run server in threaded mode, calling the application in a
    thread allowing for concurrency in the Rack adapter, closes #46
  * Guess which adapter to use from directory (chdir option)</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -13,6 +13,8 @@ require 'cgi'
 module Rack
   module Adapter 
     class Rails
+      FILE_METHODS = %w(GET HEAD).freeze
+      
       def initialize(options={})
         @root   = options[:root]         || Dir.pwd
         @env    = options[:environment]  || 'development'
@@ -56,16 +58,20 @@ module Rack
       
       def call(env)
         path        = env['PATH_INFO'].chomp('/')
+        method      = env['REQUEST_METHOD']
         cached_path = (path.empty? ? 'index' : path) + ActionController::Base.page_cache_extension
         
-        if file_exist?(path)              # Serve the file if it's there
-          serve_file(env)
-        elsif file_exist?(cached_path)    # Serve the page cache if it's there
-          env['PATH_INFO'] = cached_path
-          serve_file(env)
-        else                              # No static file, let Rails handle it
-          serve_rails(env)
+        if FILE_METHODS.include?(method)
+          if file_exist?(path)              # Serve the file if it's there
+            return serve_file(env)
+          elsif file_exist?(cached_path)    # Serve the page cache if it's there
+            env['PATH_INFO'] = cached_path
+            return serve_file(env)
+          end
         end
+        
+        # No static file, let Rails handle it
+        serve_rails(env)
       end
     
       protected</diff>
      <filename>lib/rack/adapter/rails.rb</filename>
    </modified>
    <modified>
      <diff>@@ -56,6 +56,18 @@ begin
       res.body.should == 'cached'
     end
     
+    it &quot;should not serve page cache on POST request&quot; do
+      res = @request.get(&quot;/simple/cached?value=cached&quot;)
+
+      res.should be_ok
+      res.body.should == 'cached'
+      
+      res = @request.post(&quot;/simple/cached?value=notcached&quot;)
+      
+      res.should be_ok
+      res.body.should == 'notcached'
+    end
+    
     it &quot;handles multiple cookies&quot; do
       res = @request.get('/simple/set_cookie?name=a&amp;value=1')
     </diff>
      <filename>spec/rack/rails_adapter_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8968de296a0edc8a233ae8d7d2717615f0305815</id>
    </parent>
  </parents>
  <author>
    <name>macournoyer</name>
    <email>macournoyer@gmail.com</email>
  </author>
  <url>http://github.com/macournoyer/thin/commit/1d1faea0401103e2d16cfb38b19d7fd133053cb5</url>
  <id>1d1faea0401103e2d16cfb38b19d7fd133053cb5</id>
  <committed-date>2008-04-02T17:49:23-07:00</committed-date>
  <authored-date>2008-04-02T17:49:23-07:00</authored-date>
  <message>Serve static file only on GET and HEAD requests in Rails adapter, fixes #58</message>
  <tree>fbcf407c7fe50067672e6b993de7a5d2af1a398b</tree>
  <committer>
    <name>macournoyer</name>
    <email>macournoyer@gmail.com</email>
  </committer>
</commit>
