474358 - DefaultServlet bad Content-Type on compressed content

This commit is contained in:
Greg Wilkins 2015-08-14 16:03:08 +10:00
parent 6274522787
commit 087b4c94d7
2 changed files with 4 additions and 2 deletions

View File

@ -519,7 +519,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
{
// ensure we have content
if (content==null)
content=new ResourceHttpContent(resource,_mimeTypes.getMimeByExtension(resource.toString()),response.getBufferSize(),_etags);
content=new ResourceHttpContent(resource,_mimeTypes.getMimeByExtension(pathInContext),response.getBufferSize(),_etags);
if (included.booleanValue() || passConditionalHeaders(request,response, resource,content))
{
@ -591,7 +591,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
}
else
{
content=new ResourceHttpContent(resource,_mimeTypes.getMimeByExtension(resource.toString()),_etags);
content=new ResourceHttpContent(resource,_mimeTypes.getMimeByExtension(pathInContext),_etags);
if (included.booleanValue() || passConditionalHeaders(request,response, resource,content))
sendDirectory(request,response,resource,pathInContext);
}

View File

@ -705,6 +705,7 @@ public class DefaultServletTest
String response = connector.getResponses("GET /context/data0.txt HTTP/1.0\r\nHost:localhost:8080\r\n\r\n");
assertResponseContains("Content-Length: 12", response);
assertResponseContains("Content-Type: text/plain",response);
assertResponseContains("Hello Text 0",response);
assertResponseContains("Vary: Accept-Encoding",response);
assertResponseNotContains("Content-Encoding: gzip",response);
@ -712,6 +713,7 @@ public class DefaultServletTest
response = connector.getResponses("GET /context/data0.txt HTTP/1.0\r\nHost:localhost:8080\r\nAccept-Encoding:gzip\r\n\r\n");
assertResponseContains("Content-Length: 9", response);
assertResponseContains("fake gzip",response);
assertResponseContains("Content-Type: text/plain",response);
assertResponseContains("Vary: Accept-Encoding",response);
assertResponseContains("Content-Encoding: gzip",response);