1*1c60b9acSAndroid Build Coastguard Worker# Client http cookie storage, caching and application 2*1c60b9acSAndroid Build Coastguard Worker 3*1c60b9acSAndroid Build Coastguard Workerlws now has the option to store incoming cookies in a Netscape cookie jar file 4*1c60b9acSAndroid Build Coastguard Workerpersistently, and auto-apply relevant cookies to future outgoing requests. 5*1c60b9acSAndroid Build Coastguard Worker 6*1c60b9acSAndroid Build Coastguard WorkerA L1 heap cache of recent cookies is maintained, along with LRU tracking and 7*1c60b9acSAndroid Build Coastguard Workerremoval of entries from cache and the cookie jar file according to their cookie 8*1c60b9acSAndroid Build Coastguard Workerexpiry time. 9*1c60b9acSAndroid Build Coastguard Worker 10*1c60b9acSAndroid Build Coastguard WorkerThe cookie handling is off by default per-connection for backwards compatibility 11*1c60b9acSAndroid Build Coastguard Workerand to avoid unexpected tracking. 12*1c60b9acSAndroid Build Coastguard Worker 13*1c60b9acSAndroid Build Coastguard Worker## Enabling at build-time 14*1c60b9acSAndroid Build Coastguard Worker 15*1c60b9acSAndroid Build Coastguard WorkerMake sure `-DLWS_WITH_CACHE_NSCOOKIEJAR=1` is enabled at cmake (it is on by 16*1c60b9acSAndroid Build Coastguard Workerdefault now). 17*1c60b9acSAndroid Build Coastguard Worker 18*1c60b9acSAndroid Build Coastguard Worker## Configuring the cookie cache 19*1c60b9acSAndroid Build Coastguard Worker 20*1c60b9acSAndroid Build Coastguard WorkerThe cookie cache is managed through context creation info struct members. 21*1c60b9acSAndroid Build Coastguard Worker 22*1c60b9acSAndroid Build Coastguard Worker|member|function| 23*1c60b9acSAndroid Build Coastguard Worker|---|---| 24*1c60b9acSAndroid Build Coastguard Worker|`.http_nsc_filepath`|Filepath to store the cookie jar file at| 25*1c60b9acSAndroid Build Coastguard Worker|`.http_nsc_heap_max_footprint`|0, or Max size in bytes for the L1 heap cache| 26*1c60b9acSAndroid Build Coastguard Worker|`.http_nsc_heap_max_items`|0, or Max number of cookies allowed in L1 heap cache| 27*1c60b9acSAndroid Build Coastguard Worker|`.http_nsc_heap_max_payload`|0, or Largest cookie we are willing to handle| 28*1c60b9acSAndroid Build Coastguard Worker 29*1c60b9acSAndroid Build Coastguard Worker## Enabling per-connection in lws 30*1c60b9acSAndroid Build Coastguard Worker 31*1c60b9acSAndroid Build Coastguard WorkerTo enable it on connections at lws level, add the flag `LCCSCF_CACHE_COOKIES` to 32*1c60b9acSAndroid Build Coastguard Workerthe client connection info struct `.ssl_connection` flags. 33*1c60b9acSAndroid Build Coastguard Worker 34*1c60b9acSAndroid Build Coastguard Worker## Enabling per-connection in Secure Streams policy 35*1c60b9acSAndroid Build Coastguard Worker 36*1c60b9acSAndroid Build Coastguard WorkerTo enable it on Secure Streams, in the streamtype policy add 37*1c60b9acSAndroid Build Coastguard Worker 38*1c60b9acSAndroid Build Coastguard Worker``` 39*1c60b9acSAndroid Build Coastguard Worker "http_cookies": true 40*1c60b9acSAndroid Build Coastguard Worker``` 41