PATH:
opt
/
alt
/
ruby24
/
lib64
/
ruby
/
gems
/
2.4.0
/
gems
/
rack-1.6.4
/
test
require 'time' require 'rack/conditionalget' require 'rack/mock' describe Rack::ConditionalGet do def conditional_get(app) Rack::Lint.new Rack::ConditionalGet.new(app) end should "set a 304 status and truncate body when If-Modified-Since hits" do timestamp = Time.now.httpdate app = conditional_get(lambda { |env| [200, {'Last-Modified'=>timestamp}, ['TEST']] }) response = Rack::MockRequest.new(app). get("/", 'HTTP_IF_MODIFIED_SINCE' => timestamp) response.status.should.equal 304 response.body.should.be.empty end should "set a 304 status and truncate body when If-Modified-Since hits and is higher than current time" do app = conditional_get(lambda { |env| [200, {'Last-Modified'=>(Time.now - 3600).httpdate}, ['TEST']] }) response = Rack::MockRequest.new(app). get("/", 'HTTP_IF_MODIFIED_SINCE' => Time.now.httpdate) response.status.should.equal 304 response.body.should.be.empty end should "set a 304 status and truncate body when If-None-Match hits" do app = conditional_get(lambda { |env| [200, {'Etag'=>'1234'}, ['TEST']] }) response = Rack::MockRequest.new(app). get("/", 'HTTP_IF_NONE_MATCH' => '1234') response.status.should.equal 304 response.body.should.be.empty end should "not set a 304 status if If-Modified-Since hits but Etag does not" do timestamp = Time.now.httpdate app = conditional_get(lambda { |env| [200, {'Last-Modified'=>timestamp, 'Etag'=>'1234', 'Content-Type' => 'text/plain'}, ['TEST']] }) response = Rack::MockRequest.new(app). get("/", 'HTTP_IF_MODIFIED_SINCE' => timestamp, 'HTTP_IF_NONE_MATCH' => '4321') response.status.should.equal 200 response.body.should.equal 'TEST' end should "set a 304 status and truncate body when both If-None-Match and If-Modified-Since hits" do timestamp = Time.now.httpdate app = conditional_get(lambda { |env| [200, {'Last-Modified'=>timestamp, 'Etag'=>'1234'}, ['TEST']] }) response = Rack::MockRequest.new(app). get("/", 'HTTP_IF_MODIFIED_SINCE' => timestamp, 'HTTP_IF_NONE_MATCH' => '1234') response.status.should.equal 304 response.body.should.be.empty end should "not affect non-GET/HEAD requests" do app = conditional_get(lambda { |env| [200, {'Etag'=>'1234', 'Content-Type' => 'text/plain'}, ['TEST']] }) response = Rack::MockRequest.new(app). post("/", 'HTTP_IF_NONE_MATCH' => '1234') response.status.should.equal 200 response.body.should.equal 'TEST' end should "not affect non-200 requests" do app = conditional_get(lambda { |env| [302, {'Etag'=>'1234', 'Content-Type' => 'text/plain'}, ['TEST']] }) response = Rack::MockRequest.new(app). get("/", 'HTTP_IF_NONE_MATCH' => '1234') response.status.should.equal 302 response.body.should.equal 'TEST' end should "not affect requests with malformed HTTP_IF_NONE_MATCH" do bad_timestamp = Time.now.strftime('%Y-%m-%d %H:%M:%S %z') app = conditional_get(lambda { |env| [200,{'Last-Modified'=>(Time.now - 3600).httpdate, 'Content-Type' => 'text/plain'}, ['TEST']] }) response = Rack::MockRequest.new(app). get("/", 'HTTP_IF_MODIFIED_SINCE' => bad_timestamp) response.status.should.equal 200 response.body.should.equal 'TEST' end end
[-] spec_fastcgi.rb
[edit]
[-] spec_session_pool.rb
[edit]
[-] spec_auth_basic.rb
[edit]
[-] spec_head.rb
[edit]
[-] spec_multipart.rb
[edit]
[-] spec_builder.rb
[edit]
[-] spec_config.rb
[edit]
[-] spec_recursive.rb
[edit]
[-] spec_runtime.rb
[edit]
[-] spec_server.rb
[edit]
[+]
multipart
[-] spec_commonlogger.rb
[edit]
[-] spec_nulllogger.rb
[edit]
[-] spec_file.rb
[edit]
[-] spec_rewindable_input.rb
[edit]
[+]
registering_handler
[-] spec_sendfile.rb
[edit]
[+]
unregistered_handler
[-] spec_mock.rb
[edit]
[+]
static
[-] spec_tempfile_reaper.rb
[edit]
[-] spec_content_type.rb
[edit]
[-] spec_urlmap.rb
[edit]
[-] spec_lint.rb
[edit]
[-] spec_methodoverride.rb
[edit]
[-] spec_session_memcache.rb
[edit]
[-] spec_utils.rb
[edit]
[-] spec_content_length.rb
[edit]
[-] spec_cgi.rb
[edit]
[-] spec_auth_digest.rb
[edit]
[-] spec_thin.rb
[edit]
[-] spec_showstatus.rb
[edit]
[-] spec_lock.rb
[edit]
[-] spec_mongrel.rb
[edit]
[-] spec_etag.rb
[edit]
[-] spec_chunked.rb
[edit]
[+]
..
[-] spec_request.rb
[edit]
[-] spec_body_proxy.rb
[edit]
[-] spec_static.rb
[edit]
[-] spec_cascade.rb
[edit]
[-] spec_showexceptions.rb
[edit]
[-] spec_session_abstract_id.rb
[edit]
[-] spec_directory.rb
[edit]
[+]
rackup
[-] spec_handler.rb
[edit]
[-] spec_version.rb
[edit]
[-] testrequest.rb
[edit]
[-] spec_conditionalget.rb
[edit]
[-] spec_logger.rb
[edit]
[-] spec_mime.rb
[edit]
[-] spec_response.rb
[edit]
[-] spec_webrick.rb
[edit]
[+]
cgi
[-] gemloader.rb
[edit]
[-] spec_deflater.rb
[edit]
[-] spec_session_cookie.rb
[edit]
[-] spec_lobster.rb
[edit]
[+]
builder