From dfc14f50020b3ffdcbae1b8458470fe3443a7ad8 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Wed, 18 Dec 2019 18:35:27 -0500 Subject: [PATCH] Fix compile --- .../servlet/ServletSubRequestDetails.java | 54 +++++++++---------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/servlet/ServletSubRequestDetails.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/servlet/ServletSubRequestDetails.java index 9bff9c94931..a3b42ee62c7 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/servlet/ServletSubRequestDetails.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/servlet/ServletSubRequestDetails.java @@ -22,13 +22,15 @@ package ca.uhn.fhir.rest.server.servlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; public class ServletSubRequestDetails extends ServletRequestDetails { private final ServletRequestDetails myWrap; -// private Map> myHeaders = new HashMap<>(); + private Map> myHeaders = new HashMap<>(); /** * Constructor @@ -40,12 +42,12 @@ public class ServletSubRequestDetails extends ServletRequestDetails { myWrap = theRequestDetails; -// if (theRequestDetails != null) { -// Map> headers = theRequestDetails.getHeaders(); -// for (Map.Entry> next : headers.entrySet()) { -// myHeaders.put(next.getKey().toLowerCase(), next.getValue()); -// } -// } + if (theRequestDetails != null) { + Map> headers = theRequestDetails.getHeaders(); + for (Map.Entry> next : headers.entrySet()) { + myHeaders.put(next.getKey().toLowerCase(), next.getValue()); + } + } } @Override @@ -58,36 +60,28 @@ public class ServletSubRequestDetails extends ServletRequestDetails { return myWrap.getServletResponse(); } -// public void addHeader(String theName, String theValue) { -// String lowerCase = theName.toLowerCase(); -// List list = myHeaders.get(lowerCase); -// if (list == null) { -// list = new ArrayList<>(); -// myHeaders.put(lowerCase, list); -// } -// list.add(theValue); -// } + public void addHeader(String theName, String theValue) { + String lowerCase = theName.toLowerCase(); + List list = myHeaders.computeIfAbsent(lowerCase, k -> new ArrayList<>()); + list.add(theValue); + } @Override public String getHeader(String theName) { - return myWrap.getHeader(theName); - -// List list = myHeaders.get(theName.toLowerCase()); -// if (list == null || list.isEmpty()) { -// return null; -// } -// return list.get(0); + List list = myHeaders.get(theName.toLowerCase()); + if (list == null || list.isEmpty()) { + return null; + } + return list.get(0); } @Override public List getHeaders(String theName) { - return myWrap.getHeaders(theName); - -// List list = myHeaders.get(theName.toLowerCase()); -// if (list == null || list.isEmpty()) { -// return null; -// } -// return list; + List list = myHeaders.get(theName.toLowerCase()); + if (list == null || list.isEmpty()) { + return null; + } + return list; } @Override