Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Callout-based Service Extensions : Is it possible to share data between on_request on_response?

Hello all,

I am currently doing some tests using the Callout-based Service Extensions  with python sdk.

My current uses case:

  • On on_request_headers : I need to perform an API call that will return a 403 or 200
    • If we have a 403 response, we send an imediate_response with the body and headers received from the API 
    • If we have a 200, we let the request hit the origin

This seems to work fine, however:

  • This 200 response from the API returns also a cookie that we need to send back to client.
  • And since we need to send back to the client; we need to use the function on_response_headers after hitting the origin
    • Unfortunately, I was not able to find a way to share data (inside the same request/context/thread) between on_request_headers  and on_response_headers

My question is: do you know if this is possible in this current implementation?

Thanks and best regards

 

 

1 3 360