Skip to content

Cannot use cookies anymore in userResHeaderDecorator method as response headers are replaced. #565

@legendetm

Description

@legendetm

Previously the userResHeaderDecorator returned headers override that allowed me to override/change needed headers and allowed me to set cookies to request. I was extracting value from headers and saved this to http only cookie and then changed the header value as extracted.

Now with new logic, when userResHeaderDecorator is defined, then all response headers are cleared and only returned headers added to the response. With this new logic it's not possible to add cookies in the userResHeaderDecorator method, as these cookies are cleared after the method. Now I used userResHeaderDecorator to save the header value to userReq.x_custom_value and change header value, then in userResDecorator if the userReq.x_custom_value is defined, then I save the cookie.

I think, the previous logic to override the headers was better, and when overridden header values was undefined, then the header should have been removed. Or the previous header clearing should be optional.

Also removing all headers and adding all them back does additional changes, that may not be needed in most times. The response usually have 15+ headers, and to change one, we are removing all headers and then adding them back. I think that removing all headers should not be default logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions