Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Add API for updating/serializing cookie table #34

@mamacdon

Description

@mamacdon

I'm trying to use this library in a reverse proxy that modifies a cookie header before passing the request to the upstream. For example, if an incoming request has this header:

Cookie: a=1; b=2; c=3

I want to parse it, remove b and change the value of a, producing a value like:

a=4; c=3

After that, I use a directive like proxy_set_header Cookie $new_cookies to override the cookies sent to the upstream.

Right now I can't cleanly accomplish this using lua-resty-cookie. I can parse the incoming Cookie header using get_all(), but I have to filter/modify/assemble the resulting cookie myself.

It would be helpful to have API for updating values inside the cookie table, and serializing the table to the format used in a Cookie header. E.g. something like this:

  • cookie.update(key, value) -- updates a cookie in the table
  • cookie.del(name) -- removes a cookie from the table
  • cookie.to_string() -- serializes table as a Cookie header

Would this fit within the scope of this library? Or is this project intended only as a wrapper for Set-Cookie?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions