Skip to content

Add cookie parser to echo the value of cookies in the response. Also works for signed cookies.#94

Merged
mendhak merged 4 commits intomasterfrom
cookieparser
Mar 20, 2026
Merged

Add cookie parser to echo the value of cookies in the response. Also works for signed cookies.#94
mendhak merged 4 commits intomasterfrom
cookieparser

Conversation

@mendhak
Copy link
Owner

@mendhak mendhak commented Mar 19, 2026

To sign a cookie, generate a value using

SIGNED_COOKIE=$(node -e "var crypto = require('crypto');

function sign(val, secret){
  return val + '.' + crypto
    .createHmac('sha256', secret)
    .update(val)
    .digest('base64')
    .replace(/=+$/, '');
};

console.log(sign('my-value','examplekey'));")

Start the container with the same secret key

docker run -d --rm -e COOKIE_SECRET=examplekey --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo:testing

Then send it in the header like so

curl -s http://localhost:8080/ -H "Cookie: mysigned=s:${SIGNED_COOKIE}"

Issue #93

mendhak added 4 commits March 19, 2026 23:12
…works for signed cookies.

To sign a cookie, generate a value using

SIGNED_COOKIE=$(node -e "var crypto = require('crypto');

function sign(val, secret){
  return val + '.' + crypto
    .createHmac('sha256', secret)
    .update(val)
    .digest('base64')
    .replace(/=+$/, '');
};

console.log(sign('my-value','mysecretkey123'));")

Then send it in the header like so

curl -s http://localhost:8080/ -H "Cookie: mysigned=s:${SIGNED_COOKIE}"

Issue #93
@mendhak mendhak merged commit 68c03ea into master Mar 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant