Javascript: how to imitate cookie browser implementations?

I am trying to create a fully functional web proxy using node.js, which essentially loads the web page and displays it to the client. I had a problem with the implementation of cookies, although it was harder than I thought, because they have so many rules.

Are there any libraries that have already been created to emulate how the browser handles cookies?

+6
source share
3 answers

Use request , it already processes cookie storage for successive requests in the cookie bank.

Or, if you do not want to reinvent the wheel, use Nodejitsu's node-http-proxy for a full-blown proxy.

+2
source

This video tutorial will help you perform session processing with node.js.

I hope he helps you.

+1
source

You really should take a look at the implementation of the Tobi cookie, here are some useful links:

Cookies and cookies:
https://github.com/LearnBoost/tobi/blob/master/lib/cookie/index.js https://github.com/LearnBoost/tobi/blob/master/lib/cookie/jar.js

Tests for cookies and cookies:
https://github.com/LearnBoost/tobi/blob/master/test/cookie.test.js https://github.com/LearnBoost/tobi/blob/master/test/cookie.jar.test.js

Last but not least, look at the browser file to see how they are implemented in the queries: (look for each origin of the word cookie in this file)
https://github.com/LearnBoost/tobi/blob/master/lib/browser.js

+1
source

Source: https://habr.com/ru/post/900764/


All Articles