@@ -167,25 +167,32 @@ def load_header(env, key)
167167 def load_variable ( env , key )
168168 return nil if @servlet_env . nil?
169169 case key
170- when 'CONTENT_TYPE'
171- content_type = @servlet_env . getContentType
172- env [ key ] = content_type if content_type
173- when 'CONTENT_LENGTH'
174- content_length = @servlet_env . getContentLength
175- env [ key ] = content_length . to_s if content_length >= 0
176- when 'PATH_INFO' then env [ key ] = @servlet_env . getPathInfo
177- when 'QUERY_STRING' then env [ key ] = @servlet_env . getQueryString || ''
178- when 'REMOTE_ADDR' then env [ key ] = @servlet_env . getRemoteAddr || ''
179- when 'REMOTE_HOST' then env [ key ] = @servlet_env . getRemoteHost || ''
180- when 'REMOTE_USER' then env [ key ] = @servlet_env . getRemoteUser || ''
181- when 'REQUEST_METHOD' then env [ key ] = @servlet_env . getMethod || 'GET'
182- when 'REQUEST_URI' then env [ key ] = @servlet_env . getRequestURI
183- when 'SCRIPT_NAME' then env [ key ] = @servlet_env . getScriptName
184- when 'SERVER_NAME' then env [ key ] = @servlet_env . getServerName || ''
185- when 'SERVER_PORT' then env [ key ] = @servlet_env . getServerPort . to_s
186- when 'SERVER_SOFTWARE' then env [ key ] = rack_context . getServerInfo
187- else
188- nil
170+ when 'CONTENT_TYPE'
171+ content_type = @servlet_env . getContentType
172+ env [ key ] = content_type if content_type
173+ when 'CONTENT_LENGTH'
174+ content_length = @servlet_env . getContentLength
175+ env [ key ] = content_length . to_s if content_length >= 0
176+ when 'PATH_INFO' then env [ key ] = @servlet_env . getPathInfo
177+ when 'QUERY_STRING' then env [ key ] = @servlet_env . getQueryString || ''
178+ when 'REMOTE_ADDR' then env [ key ] = @servlet_env . getRemoteAddr || ''
179+ when 'REMOTE_HOST' then env [ key ] = @servlet_env . getRemoteHost || ''
180+ when 'REMOTE_USER' then env [ key ] = @servlet_env . getRemoteUser || ''
181+ when 'REQUEST_METHOD' then env [ key ] = @servlet_env . getMethod || 'GET'
182+ when 'REQUEST_URI' then env [ key ] = @servlet_env . getRequestURI
183+ when 'SCRIPT_NAME' then env [ key ] = @servlet_env . getScriptName
184+ when 'SERVER_NAME' then env [ key ] = @servlet_env . getServerName || ''
185+ when 'SERVER_PORT' then env [ key ] = @servlet_env . getServerPort . to_s
186+ when 'SERVER_SOFTWARE' then env [ key ] = rack_context . getServerInfo
187+ else
188+ # NOTE: even though we allowed for overrides and loaded all attributes
189+ # up front (looping thru getAttributeNames) container "hidden" attribs
190+ # might still get resolved e.g. 'org.apache.tomcat.sendfile.support'
191+ if hidden_attr = @servlet_env . getAttribute ( key )
192+ env [ key ] = hidden_attr
193+ else
194+ nil
195+ end
189196 end
190197 end
191198
0 commit comments