Hi there,
I am trying to access multiple Cookies from the header in a response. I've tried both these model but they both return only one string.
Thanks for any advice.
models:
authTokenResponse:
type: "object"
location: "header"
properties:
set-cookie:
location: "header"
type: "array"
models:
authTokenResponse:
type: "object"
location: "header"
properties:
set-cookie:
location: "header"
type: "string"
Comments
Comment #2
redsky commentedFull disclosure I cut back the model to the relevant parts that show how I've been trying to access the cookies.
Comment #3
redsky commentedI guess it might be more helpful if I explain my full use case and share some logs. I'm calling an API that requires getting an auth token with a first call and uses a session cookie. So perhaps my question is simple, how do I accept a cookie in and have it persist for the second call where the actual work happens? I was trying to read the cookie from the first response header and set it in the second request header - this works in straight guzzle but as noted above, I'm not able to (or don't know how) access all the cookies using a response model.
Here's my anonymized debug log.
Comment #4
aronne commentedHi @redsky,
you should use the Handler Stack as described here: https://www.drupal.org/docs/8/modules/http-client-manager/the-handler-stack
Use the handler stack to perform your first request and set the cookie you'll later use on your second request.
Regards,
aronne