e2475825 by Adam Heath

Merge branch 'BF-8039' of /home/git/repositories/brainfood/ofbiz-directcontrolservlet

2 parents 249f5ebb 80ba65d8
......@@ -453,10 +453,34 @@ public class DirectControlServlet extends HttpServlet {
context.put("httpProtocol", request.getProtocol());
context.put("httpScheme", request.getScheme());
Enumeration<String> headerNames = request.getHeaderNames();
Map<String, List<String>> headerMap = new HashMap<String, List<String>>();
while (headerNames.hasMoreElements()) {
String headerName = headerNames.nextElement();
headerMap.put(headerName, Collections.list(request.getHeaders(headerName)));
}
context.put("httpHeaders", headerMap);
context = model.makeValid(context, ModelService.IN_PARAM, true, errorMessages, timeZone, locale);
Map<String, Object> result = dispatcher.runSync(serviceName, context);
if (result.get("httpHeaders") != null) {
Map<String, List<String>> headers = (Map<String,List<String>>) result.get("httpHeaders");
for (Map.Entry<String, List<String>> header : headers.entrySet()) {
for (String value : header.getValue()) {
response.addHeader(header.getKey(), value);
}
}
}
if (result.get("httpCookies") != null) {
List<Cookie> cookies = (List<Cookie>) result.get("httpCookies");
for (Cookie cookie : cookies) {
response.addCookie(cookie);
}
}
result.remove("responseMessage");
Integer httpStatusCode = (Integer) result.remove("httpStatusCode");
int statusCode = httpStatusCode == null ? 200 : httpStatusCode.intValue();
......