Sha256: 51f349c5fad9c8c7d8f74cdc3f270c2b92c4ad7657be6be0114f01ace93604cd

Contents?: true

Size: 819 Bytes

Versions: 25

Compression:

Stored size: 819 Bytes

Contents

module Merb
  module Rack

    class ConditionalGet < Merb::Rack::Middleware

      # :api: plugin
      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
      # :api: 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

25 entries across 25 versions & 1 rubygems

Version Path
merb-core-1.1.3 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.1.2 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.1.1 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.1.0 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.1.0.rc1 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.1.0.pre lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.0.15 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.0.14 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.0.13 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.0.12 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.0.2 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.0.1 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.0.10 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.0.11 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.0.3 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.0.4 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.0.6.1 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.0.5 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.0.8.1 lib/merb-core/rack/middleware/conditional_get.rb
merb-core-1.0.6 lib/merb-core/rack/middleware/conditional_get.rb