fjtirado commented on code in PR #3937:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/3937#discussion_r2439418785


##########
kogito-serverless-workflow/kogito-serverless-workflow-rest-runtime/src/main/java/org/kie/kogito/serverless/workflow/rest/JsonNodeResultHandler.java:
##########
@@ -33,18 +33,35 @@
 
 public class JsonNodeResultHandler implements RestWorkItemHandlerResult {
 
-    static final String STATUS_CODE = "statusCode";
-    static final String STATUS_MESSAGE = "statusMessage";
+    public static final String RETURN_HEADERS = "returnHeaders";
+    public static final String RETURN_STATUS_CODE = "returnStatusCode";
+    public static final String RETURN_STATUS_MESSAGE = "returnStatusMessage";
+    public static final String FAIL_ON_STATUS_ERROR = "failOnStatusCode";
+    public static final String STATUS_CODE = "statusCode";
+    public static final String STATUS_MESSAGE = "statusMessage";
+    public static final String RESPONSE_HEADERS = "responseHeaders";
 
     @Override
     public Object apply(HttpResponse<Buffer> t, Class<?> u, 
KogitoProcessContext context) {
         Map<String, Object> metadata = 
context.getNodeInstance().getNode().getMetaData();
-        if (metadata == null || 
toBoolean(metadata.getOrDefault("failOnStatusCode", Boolean.TRUE))) {
+        if (metadata == null || 
toBoolean(metadata.getOrDefault(FAIL_ON_STATUS_ERROR, Boolean.TRUE))) {
             checkStatusCode(t);
-        } else {
-            context.setVariable(STATUS_CODE, t.statusCode());
-            context.setVariable(STATUS_MESSAGE, t.statusMessage());
         }
+
+        if (metadata != null) {
+            if (toBoolean(metadata.getOrDefault(RETURN_STATUS_CODE, 
Boolean.TRUE))) {

Review Comment:
   I do not think this check is needed at all, failOnstatusCode check is needed 
because default behaviour when there is an error is to throw an exception, but 
headers can be added to context outside the if-else, without need to check for 
metadata
   and setVariable status_code and setVariable status:message should remain as 
they were (only added when failOnStatusCode is set to false)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to