Fix compile

This commit is contained in:
James Agnew 2019-12-18 18:35:27 -05:00
parent e9811c6377
commit dfc14f5002
1 changed files with 24 additions and 30 deletions

View File

@ -22,13 +22,15 @@ package ca.uhn.fhir.rest.server.servlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class ServletSubRequestDetails extends ServletRequestDetails { public class ServletSubRequestDetails extends ServletRequestDetails {
private final ServletRequestDetails myWrap; private final ServletRequestDetails myWrap;
// private Map<String, List<String>> myHeaders = new HashMap<>(); private Map<String, List<String>> myHeaders = new HashMap<>();
/** /**
* Constructor * Constructor
@ -40,12 +42,12 @@ public class ServletSubRequestDetails extends ServletRequestDetails {
myWrap = theRequestDetails; myWrap = theRequestDetails;
// if (theRequestDetails != null) { if (theRequestDetails != null) {
// Map<String, List<String>> headers = theRequestDetails.getHeaders(); Map<String, List<String>> headers = theRequestDetails.getHeaders();
// for (Map.Entry<String, List<String>> next : headers.entrySet()) { for (Map.Entry<String, List<String>> next : headers.entrySet()) {
// myHeaders.put(next.getKey().toLowerCase(), next.getValue()); myHeaders.put(next.getKey().toLowerCase(), next.getValue());
// } }
// } }
} }
@Override @Override
@ -58,36 +60,28 @@ public class ServletSubRequestDetails extends ServletRequestDetails {
return myWrap.getServletResponse(); return myWrap.getServletResponse();
} }
// public void addHeader(String theName, String theValue) { public void addHeader(String theName, String theValue) {
// String lowerCase = theName.toLowerCase(); String lowerCase = theName.toLowerCase();
// List<String> list = myHeaders.get(lowerCase); List<String> list = myHeaders.computeIfAbsent(lowerCase, k -> new ArrayList<>());
// if (list == null) { list.add(theValue);
// list = new ArrayList<>(); }
// myHeaders.put(lowerCase, list);
// }
// list.add(theValue);
// }
@Override @Override
public String getHeader(String theName) { public String getHeader(String theName) {
return myWrap.getHeader(theName); List<String> list = myHeaders.get(theName.toLowerCase());
if (list == null || list.isEmpty()) {
// List<String> list = myHeaders.get(theName.toLowerCase()); return null;
// if (list == null || list.isEmpty()) { }
// return null; return list.get(0);
// }
// return list.get(0);
} }
@Override @Override
public List<String> getHeaders(String theName) { public List<String> getHeaders(String theName) {
return myWrap.getHeaders(theName); List<String> list = myHeaders.get(theName.toLowerCase());
if (list == null || list.isEmpty()) {
// List<String> list = myHeaders.get(theName.toLowerCase()); return null;
// if (list == null || list.isEmpty()) { }
// return null; return list;
// }
// return list;
} }
@Override @Override