Merge pull request #1641 from jamesagnew/ja_20191218_trim_subrequest
Trim subrequest
This commit is contained in:
commit
345acdf24b
|
@ -20,6 +20,8 @@ package ca.uhn.fhir.rest.server.servlet;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -27,6 +29,7 @@ import java.util.Map;
|
|||
|
||||
public class ServletSubRequestDetails extends ServletRequestDetails {
|
||||
|
||||
private final ServletRequestDetails myWrap;
|
||||
private Map<String, List<String>> myHeaders = new HashMap<>();
|
||||
|
||||
/**
|
||||
|
@ -36,6 +39,9 @@ public class ServletSubRequestDetails extends ServletRequestDetails {
|
|||
*/
|
||||
public ServletSubRequestDetails(ServletRequestDetails theRequestDetails) {
|
||||
super(theRequestDetails.getInterceptorBroadcaster());
|
||||
|
||||
myWrap = theRequestDetails;
|
||||
|
||||
if (theRequestDetails != null) {
|
||||
Map<String, List<String>> headers = theRequestDetails.getHeaders();
|
||||
for (Map.Entry<String, List<String>> next : headers.entrySet()) {
|
||||
|
@ -44,13 +50,19 @@ public class ServletSubRequestDetails extends ServletRequestDetails {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpServletRequest getServletRequest() {
|
||||
return myWrap.getServletRequest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpServletResponse getServletResponse() {
|
||||
return myWrap.getServletResponse();
|
||||
}
|
||||
|
||||
public void addHeader(String theName, String theValue) {
|
||||
String lowerCase = theName.toLowerCase();
|
||||
List<String> list = myHeaders.get(lowerCase);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
myHeaders.put(lowerCase, list);
|
||||
}
|
||||
List<String> list = myHeaders.computeIfAbsent(lowerCase, k -> new ArrayList<>());
|
||||
list.add(theValue);
|
||||
}
|
||||
|
||||
|
@ -72,6 +84,11 @@ public class ServletSubRequestDetails extends ServletRequestDetails {
|
|||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Object, Object> getUserData() {
|
||||
return myWrap.getUserData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSubRequest() {
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue