Layer7 API Management

  • 1.  Send response with Return template to requester !

    Posted Jul 22, 2016 08:41 AM

    Hi All,

    I have captured the response with http route assertion and stored it in a variable. Now I am validating few conditions like comparing "Etag" header in the response with the input request's "if-none-match" header and then finally send response to requester accordingly after the comparison, with either the response content that was previously stored in a variable or send HTTP 304 stating that content didn't change (if etag matches the input header if-none-match).

     

    Now the problem here is, I am only able to send the response content to the requester with return template but not all the response headers. I want to have a solution where I need to send the response stored in a context variable along with all the response headers and cookies if any to the requester. And other important point here is, if response headers dont have Etag, then I am using Hash generation assertion using MD5 and creating a Etag response header manually with that hash value using Add response header assertion. I even want to sent this header with the response to the client browser.

     

    Could someone please help me here..?

     

    Thanks.



  • 2.  Re: Send response with Return template to requester !
    Best Answer

    Broadcom Employee
    Posted Jul 28, 2016 11:13 AM

    Instead of saving the response to a variable, can you save it to the default response object? I did a quick test and if the original backend response is saved to the default response message, then you can still do a Return Template Response to change the response code and body, but it appears to preserve the headers and cookies. Otherwise, if you use your own context variable to save the original response, you'd have to manually copy the cookies and headers by looping through the <message_var>.http.allheadervalues to copy them over which would not be ideal (but is possible if the other approach does not work).



  • 3.  Re: Send response with Return template to requester !

    Posted Jul 31, 2016 01:39 AM

    Thanks Gregory Thompson!!

    I have used the default response variable instead of saving it to a variable and it worked.

     

    -Vivek