diff --git a/vendor/js-test-core/.piston.yml b/vendor/js-test-core/.piston.yml index 08b93c0..dec12cc 100644 --- a/vendor/js-test-core/.piston.yml +++ b/vendor/js-test-core/.piston.yml @@ -1,7 +1,7 @@ --- format: 1 handler: - commit: 15f328216186294f2a3b4494449b92d1ac787fbd + commit: b161d7fcd06a93938c748b66ad524f3a29c60b3c branch: HEAD lock: false repository_url: git://github.com/pivotal/js-test-core.git diff --git a/vendor/js-test-core/lib/js_test_core/resources/file.rb b/vendor/js-test-core/lib/js_test_core/resources/file.rb index 82fadad..026591f 100644 --- a/vendor/js-test-core/lib/js_test_core/resources/file.rb +++ b/vendor/js-test-core/lib/js_test_core/resources/file.rb @@ -8,29 +8,29 @@ class File < ThinRest::Resource '.jpg' => 'image/jpeg', '.jpeg' => 'image/jpeg', '.gif' => 'image/gif', - } + } property :absolute_path, :relative_path def get extension = ::File.extname(absolute_path) content_type = MIME_TYPES[extension] || 'text/html' - - if !rack_request.env["HTTP_IF_MODIFIED_SINCE"].to_s.empty? && Time.parse(rack_request.env["HTTP_IF_MODIFIED_SINCE"]) >= ::File.mtime(absolute_path) - connection.send_head( - 304, - 'Content-Type' => content_type, - 'Last-Modified' => ::File.mtime(absolute_path).rfc822, - 'Content-Length' => 0 - ) - else - connection.send_head( - 200, - 'Content-Type' => content_type, - 'Last-Modified' => ::File.mtime(absolute_path).rfc822, - 'Content-Length' => ::File.size(absolute_path) - ) - connection.terminate_after_sending do + + connection.terminate_after_sending do + if !rack_request.env["HTTP_IF_MODIFIED_SINCE"].to_s.empty? && Time.parse(rack_request.env["HTTP_IF_MODIFIED_SINCE"]) >= ::File.mtime(absolute_path) + connection.send_head( + 304, + 'Content-Type' => content_type, + 'Last-Modified' => ::File.mtime(absolute_path).rfc822, + 'Content-Length' => 0 + ) + else + connection.send_head( + 200, + 'Content-Type' => content_type, + 'Last-Modified' => ::File.mtime(absolute_path).rfc822, + 'Content-Length' => ::File.size(absolute_path) + ) ::File.open(absolute_path) do |file| while !file.eof? connection.send_data(file.read(1024)) @@ -38,12 +38,12 @@ def get end end end - end - def ==(other) - return false unless other.class == self.class - absolute_path == other.absolute_path && relative_path == other.relative_path + def ==(other) + return false unless other.class == self.class + absolute_path == other.absolute_path && relative_path == other.relative_path + end end end end -end \ No newline at end of file +end diff --git a/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb b/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb index 05f281c..ed619c8 100644 --- a/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb +++ b/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb @@ -14,8 +14,11 @@ module Resources it "returns a 304 response with Content-Length: 0 and Last-Modified: File.mtime" do path = "#{public_path}/stylesheets/example.css" mock(connection).send_head(304, 'Content-Type' => "text/css", 'Content-Length' => 0, 'Last-Modified' => ::File.mtime(path).rfc822) - connection.receive_data("GET /stylesheets/example.css HTTP/1.1\r\nHost: _\r\nIf-Modified-Since: #{::File.mtime(path).rfc822}\r\n\r\n") + + path_2 = "#{public_path}/javascripts/foo.js" + mock(connection).send_head(304, 'Content-Type' => "text/javascript", 'Content-Length' => 0, 'Last-Modified' => ::File.mtime(path_2).rfc822) + connection.receive_data("GET /javascripts/foo.js HTTP/1.1\r\nHost: _\r\nIf-Modified-Since: #{::File.mtime(path_2).rfc822}\r\n\r\n") end end @@ -23,8 +26,11 @@ module Resources it "returns a 304 response with Content-Length: 0 and Last-Modified: File.mtime" do path = "#{public_path}/stylesheets/example.css" mock(connection).send_head(304, 'Content-Type' => "text/css", 'Content-Length' => 0, 'Last-Modified' => ::File.mtime(path).rfc822) - connection.receive_data("GET /stylesheets/example.css HTTP/1.1\r\nHost: _\r\nIf-Modified-Since: #{(::File.mtime(path) + 10).rfc822}\r\n\r\n") + + path_2 = "#{public_path}/javascripts/foo.js" + mock(connection).send_head(304, 'Content-Type' => "text/javascript", 'Content-Length' => 0, 'Last-Modified' => ::File.mtime(path_2).rfc822) + connection.receive_data("GET /javascripts/foo.js HTTP/1.1\r\nHost: _\r\nIf-Modified-Since: #{(::File.mtime(path_2) + 10).rfc822}\r\n\r\n") end end @@ -33,8 +39,12 @@ module Resources path = "#{public_path}/stylesheets/example.css" mock(connection).send_head(200, 'Content-Type' => "text/css", 'Content-Length' => ::File.size(path), 'Last-Modified' => ::File.mtime(path).rfc822) mock(connection).send_data(::File.read(path)) - connection.receive_data("GET /stylesheets/example.css HTTP/1.1\r\nHost: _\r\nIf-Modified-Since: #{(::File.mtime(path) - 10).rfc822}\r\n\r\n") + + path_2 = "#{public_path}/javascripts/foo.js" + mock(connection).send_head(200, 'Content-Type' => "text/javascript", 'Content-Length' => ::File.size(path_2), 'Last-Modified' => ::File.mtime(path_2).rfc822) + mock(connection).send_data(::File.read(path_2)) + connection.receive_data("GET /javascripts/foo.js HTTP/1.1\r\nHost: _\r\nIf-Modified-Since: #{(::File.mtime(path_2) - 10).rfc822}\r\n\r\n") end end