From 241ef907691a41af8b26d99551058565a7771264 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 13 Jul 2016 12:29:02 -0700 Subject: [PATCH] Issue #721 - Enhancing multi-line response header testcase --- .../jetty/servlet/ResponseHeadersTest.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ResponseHeadersTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ResponseHeadersTest.java index 25b1def6c5a..40f74a3bf79 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ResponseHeadersTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ResponseHeadersTest.java @@ -22,6 +22,7 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import java.io.IOException; +import java.net.URLDecoder; import java.nio.ByteBuffer; import javax.servlet.ServletException; @@ -33,7 +34,6 @@ import org.eclipse.jetty.http.HttpTester; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.server.LocalConnector; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.util.BufferUtil; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -59,7 +59,12 @@ public class ResponseHeadersTest protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException { // The bad use-case - response.setHeader("X-example", req.getPathInfo()); + String pathInfo = req.getPathInfo(); + if(pathInfo != null && pathInfo.length() > 1 && pathInfo.startsWith("/")) + { + pathInfo = pathInfo.substring(1); + } + response.setHeader("X-example", pathInfo); // The correct use response.setContentType("text/plain"); @@ -122,19 +127,26 @@ public class ResponseHeadersTest @Test public void testMultilineResponseHeaderValue() throws Exception { + String actualPathInfo = "%0A%20Content-Type%3A%20image/png%0A%20Content-Length%3A%208%0A%20%0A%20yuck