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 { ...@@ -453,10 +453,34 @@ public class DirectControlServlet extends HttpServlet {
453 context.put("httpProtocol", request.getProtocol()); 453 context.put("httpProtocol", request.getProtocol());
454 context.put("httpScheme", request.getScheme()); 454 context.put("httpScheme", request.getScheme());
455 455
456 Enumeration<String> headerNames = request.getHeaderNames();
457 Map<String, List<String>> headerMap = new HashMap<String, List<String>>();
458 while (headerNames.hasMoreElements()) {
459 String headerName = headerNames.nextElement();
460 headerMap.put(headerName, Collections.list(request.getHeaders(headerName)));
461 }
462 context.put("httpHeaders", headerMap);
463
456 context = model.makeValid(context, ModelService.IN_PARAM, true, errorMessages, timeZone, locale); 464 context = model.makeValid(context, ModelService.IN_PARAM, true, errorMessages, timeZone, locale);
457 465
458 Map<String, Object> result = dispatcher.runSync(serviceName, context); 466 Map<String, Object> result = dispatcher.runSync(serviceName, context);
459 467
468 if (result.get("httpHeaders") != null) {
469 Map<String, List<String>> headers = (Map<String,List<String>>) result.get("httpHeaders");
470 for (Map.Entry<String, List<String>> header : headers.entrySet()) {
471 for (String value : header.getValue()) {
472 response.addHeader(header.getKey(), value);
473 }
474 }
475 }
476
477 if (result.get("httpCookies") != null) {
478 List<Cookie> cookies = (List<Cookie>) result.get("httpCookies");
479 for (Cookie cookie : cookies) {
480 response.addCookie(cookie);
481 }
482 }
483
460 result.remove("responseMessage"); 484 result.remove("responseMessage");
461 Integer httpStatusCode = (Integer) result.remove("httpStatusCode"); 485 Integer httpStatusCode = (Integer) result.remove("httpStatusCode");
462 int statusCode = httpStatusCode == null ? 200 : httpStatusCode.intValue(); 486 int statusCode = httpStatusCode == null ? 200 : httpStatusCode.intValue();
......