File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
lib/action_dispatch/middleware Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ def call(env)
4848 if gzip_path && gzip_encoding_accepted? ( env )
4949 env [ 'PATH_INFO' ] = gzip_path
5050 status , headers , body = @file_server . call ( env )
51+ if status == 304
52+ return [ status , headers , body ]
53+ end
5154 headers [ 'Content-Encoding' ] = 'gzip'
5255 headers [ 'Content-Type' ] = content_type ( path )
5356 else
Original file line number Diff line number Diff line change @@ -145,6 +145,16 @@ def test_serves_gzip_with_propper_content_type_fallback
145145 assert_equal default_response . headers [ 'Content-Type' ] , response . headers [ 'Content-Type' ]
146146 end
147147
148+ def test_serves_gzip_files_with_not_modified
149+ file_name = "/gzip/application-a71b3024f80aea3181c09774ca17e712.js"
150+ last_modified = File . mtime ( File . join ( @root , "#{ file_name } .gz" ) )
151+ response = get ( file_name , 'HTTP_ACCEPT_ENCODING' => 'gzip' , 'HTTP_IF_MODIFIED_SINCE' => last_modified . httpdate )
152+ assert_equal 304 , response . status
153+ assert_equal nil , response . headers [ 'Content-Type' ]
154+ assert_equal nil , response . headers [ 'Content-Encoding' ]
155+ assert_equal nil , response . headers [ 'Vary' ]
156+ end
157+
148158 # Windows doesn't allow \ / : * ? " < > | in filenames
149159 unless RbConfig ::CONFIG [ 'host_os' ] =~ /mswin|mingw/
150160 def test_serves_static_file_with_colon
You can’t perform that action at this time.
0 commit comments