pfernie / reqwest_cookie_store

Apache License 2.0
26 stars 16 forks source link

Use a valid json format to store cookies. #10

Closed dcampbell24 closed 3 weeks ago

dcampbell24 commented 3 months ago

You can't parse the cookies with let cookies: serde_json::Value = serde_json::from_str(&data).unwrap();, because you store the cookies in an invalid json format. Why not just stick the cookies in an Array?

pfernie commented 3 months ago

The de/serialization behavior here is actually implemented in the underlying cookie_store crate. It is true the behavior there is line-oriented (serializing each cookie individually). The crate provides some methods that abstract over the serialization method, with the intent of supporting other formats such as the curl cookie file format and the like. In practice, JSON is the only target format that is used (AFAIK).

That being said, I wouldn't want to change the existing behavior of these methods as this would be breaking for current users/serialized cookie sets. I would be happy to review a PR (on cookie_store) introducing alternative serializations, however.

dcampbell24 commented 3 months ago

I created a pull request with some ideas.

pfernie commented 3 weeks ago

Closing as discussion is occurring on the PR