Skip to content

Add operator to fetch cookies by their key#1312

Open
Callen44 wants to merge 1 commit into
libcpr:masterfrom
Callen44:master
Open

Add operator to fetch cookies by their key#1312
Callen44 wants to merge 1 commit into
libcpr:masterfrom
Callen44:master

Conversation

@Callen44

@Callen44 Callen44 commented Jul 1, 2026

Copy link
Copy Markdown

The main idea of this PR is to add the ability to fetch cookies by their individual key from a cpr::Cookies object. calling the [] operator on a string storing the cookie name would return the actual cookie with that name, if not, it throws std::out_of_range. Looping through the list of cookies produces annoying boilerplate code, and this would fix that. I'm a new C++ programmer; worse yet, my introduction to C++ was with version 98, so I won't be offended by quite possibly a lot of feedback.

I already have these concerns with my own PR, however.

  1. The idea of a Cookies object is to be vector-like, and this code intentionally more map-like; I'm not sure if the very concept is out-of-place or not.
  2. Looping through cookies like this could become very inefficient for large cookie lists (I'm not sure if that kind of speed is a priority in cpr or not).
  3. There's always the problem of a given cookie not being possible to find, I'd love some help on whether throwing std::out_of_range is the right way to handle that.

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