lib/roda/plugins/caching.rb
def etag(value, opts=OPTS)
          # Before touching this code, please double check RFC 2616 14.24 and 14.26.
          weak = opts[:weak]
          new_resource = opts.fetch(:new_resource){post?}

          res = response
          e = env
          res['ETag'] = etag = "#{'W/' if weak}\"#{value}\""
          status = res.status

          if (!status || (status >= 200 && status < 300) || status == 304)
            if etag_matches?(e['HTTP_IF_NONE_MATCH'], etag, new_resource)
              res.status = (request_method =~ /\AGET|HEAD|OPTIONS|TRACE\z/i ? 304 : 412)
              halt
            end

            if ifm = e['HTTP_IF_MATCH']
              unless etag_matches?(ifm, etag, new_resource)
                res.status = 412
                halt
              end
            end
          end
        end
# Set the response entity tag using the ETag header.
#
# The +value+ argument is an identifier that uniquely
# identifies the current version of the resource.
# Options:
# :weak :: Use a weak cache validator (a strong cache validator is the default)
# :new_resource :: Whether this etag should match an etag of * (true for POST, false otherwise)
#
# When the current request includes an If-None-Match header with a
# matching etag, immediately returns a response with a 304 or 412 status,
# depending on the request method.
#
# When the current request includes an If-Match header with a
# etag that doesn't match, immediately returns a response with a 412 status.
Set the response entity tag using the ETag header.
The +value+ argument is an identifier that uniquely
identifies the current version of the resource.

When the current request includes an If-None-Match header with a
matching etag, immediately returns a response with a 304 or 412 status,
depending on the request method.

When the current request includes an If-Match header with a
etag that doesn't match, immediately returns a response with a 412 status.
Set the response entity tag using the ETag header . The + value + argument is an identifier that uniquely identifies the current version of the resource . When the current request includes an If - None - Match header with a matching etag immediately returns a response with a 304 or 412 status depending on the request method . When the current request includes an If - Match header with a etag that doesn ' t match immediately returns a response with a 412 status .
def etag(value, opts=OPTS)
          weak = opts[:weak]
          new_resource = opts.fetch(:new_resource){post?}
          res = response
          e = env
          res['ETag'] = etag = "#{'W/' if weak}\"#{value}\""
          status = res.status
          if (!status || (status >= 200 && status < 300) || status == 304)
            if etag_matches?(e['HTTP_IF_NONE_MATCH'], etag, new_resource)
              res.status = (request_method =~ /\AGET|HEAD|OPTIONS|TRACE\z/i ? 304 : 412)
              halt
            end
            if ifm = e['HTTP_IF_MATCH']
              unless etag_matches?(ifm, etag, new_resource)
                res.status = 412
                halt
              end
            end
          end
        end
def etag ( value , opts = OPTS ) weak = opts [ :weak ] new_resource = opts . fetch ( :new_resource ) { post? } res = response e = env res [ 'ETag' ] = etag = "#{'W/' if weak}\"#{value}\"" status = res . status if ( ! status || ( status >= 200 && status < 300 ) || status == 304 ) if etag_matches? ( e [ 'HTTP_IF_NONE_MATCH' ] , etag , new_resource ) res . status = ( request_method =~ / \A GET|HEAD|OPTIONS|TRACE \z /i ? 304 : 412 ) halt end if ifm = e [ 'HTTP_IF_MATCH' ] unless etag_matches? ( ifm , etag , new_resource ) res . status = 412 halt end end end end
Set the response entity tag using the ETag header.
Set the response entity tag using the ETag header .
# Before touching this code, please double check RFC 2616 14.24 and 14.26.
value
opts