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?
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:
I want to parse it, remove
b
and change the value ofa
, producing a value like: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
?