Skip to content

Commit

Permalink
Fix #41 Make HTTP header checks case insensitive for header names
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Thomas <markt@apache.org>
  • Loading branch information
markt-asf committed Feb 8, 2019
1 parent 5400648 commit dc4832c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/com/sun/ts/tests/servlet/spec/serverpush/Client.java
Expand Up @@ -246,23 +246,22 @@ public void serverPushInitTest() throws Fault {
+ "HttpServletRequest should be added to the builder");
}

if (response.contains("If-Match")) {
if (response.contains("if-match")) {
throw new Fault(
"Test fail: Conditional headers should NOT be added to the builder");
}

if (response.contains("Range")) {
if (response.contains("range")) {
throw new Fault(
"Test fail: Range headers should NOT be added to the builder");
}

if (!response.contains("Authorization")) {
if (!response.contains("authorization")) {
throw new Fault(
"Test fail: Authorization headers should be added to the builder");
}

if (!(response.contains("referer=" + requestURI)
|| response.contains("Referer=" + requestURI))) {
if (!response.contains("referer=" + requestURI)) {
throw new Fault(
"Test fail: Referer headers should be set to " + requestURI);
}
Expand Down
Expand Up @@ -24,6 +24,7 @@
import javax.servlet.http.PushBuilder;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Locale;

public class TestServlet2 extends HttpServlet {

Expand All @@ -40,7 +41,11 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
pw.println("JSESSIONID: " + pb.getSessionId());
pw.println("The headers of PushBuilder: ");
for (String name : pb.getHeaderNames()) {
pw.print(name);
/*
* Header names are case insensitive. Force to lower case to make client
* side test logic simpler.
*/
pw.print(name.toLowerCase(Locale.ENGLISH));
pw.print("=");
pw.println(pb.getHeader(name));
}
Expand Down

0 comments on commit dc4832c

Please sign in to comment.