Sha256: 7de5ab7c1d5639bcb90a5970ba87335fa2e58285e9707bd3ec2fa70270e1e85d

Contents?: true

Size: 775 Bytes

Versions: 11

Compression:

Stored size: 775 Bytes

Contents

module Merb
  module Rack

    class ConditionalGet < Merb::Rack::Middleware
      def call(env)
        status, headers, body = @app.call(env)

        if document_not_modified?(env, headers)
          status = 304
          body = Merb::Const::EMPTY_STRING
          # set Date header using RFC1123 date format as specified by HTTP
          # RFC2616 section 3.3.1.
        end
        
        [status, headers, body]
      end
    
    private
      def document_not_modified?(env, headers)
        if etag = headers[Merb::Const::ETAG]
          etag == env[Merb::Const::HTTP_IF_NONE_MATCH]
        elsif last_modified = headers[Merb::Const::LAST_MODIFIED]
          last_modified == env[Merb::Const::HTTP_IF_MODIFIED_SINCE]
        end
      end
    end
    
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/rack/middleware/conditional_get.rb
merb-core-0.9.10 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-0.9.13 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-0.9.11 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-0.9.12 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-0.9.9 lib/merb-core/rack/middleware/conditional_get.rb