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%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -27,6 +29,7 @@ import java.util.Map;
|
||||||
|
|
||||||
public class ServletSubRequestDetails extends ServletRequestDetails {
|
public class ServletSubRequestDetails extends ServletRequestDetails {
|
||||||
|
|
||||||
|
private final ServletRequestDetails myWrap;
|
||||||
private Map<String, List<String>> myHeaders = new HashMap<>();
|
private Map<String, List<String>> myHeaders = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,6 +39,9 @@ public class ServletSubRequestDetails extends ServletRequestDetails {
|
||||||
*/
|
*/
|
||||||
public ServletSubRequestDetails(ServletRequestDetails theRequestDetails) {
|
public ServletSubRequestDetails(ServletRequestDetails theRequestDetails) {
|
||||||
super(theRequestDetails.getInterceptorBroadcaster());
|
super(theRequestDetails.getInterceptorBroadcaster());
|
||||||
|
|
||||||
|
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()) {
|
||||||
|
@ -44,16 +50,22 @@ 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) {
|
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 = new ArrayList<>();
|
|
||||||
myHeaders.put(lowerCase, list);
|
|
||||||
}
|
|
||||||
list.add(theValue);
|
list.add(theValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHeader(String theName) {
|
public String getHeader(String theName) {
|
||||||
List<String> list = myHeaders.get(theName.toLowerCase());
|
List<String> list = myHeaders.get(theName.toLowerCase());
|
||||||
|
@ -72,6 +84,11 @@ public class ServletSubRequestDetails extends ServletRequestDetails {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Object, Object> getUserData() {
|
||||||
|
return myWrap.getUserData();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSubRequest() {
|
public boolean isSubRequest() {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue