Skip to content

Commit

Permalink
Burl: add --junk-session-cookies option
Browse files Browse the repository at this point in the history
  • Loading branch information
ashtum committed Nov 9, 2024
1 parent ebe2e2b commit 02fe354
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions example/client/burl/cookie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,19 @@ cookie_jar::make_field(const urls::url_view& url)
return rs;
}

void
cookie_jar::clear_session_cookies()
{
cookies_.erase(
std::remove_if(
cookies_.begin(),
cookies_.end(),
[](const pair_t& p) {
return !p.c.expires.has_value();
}),
cookies_.end());
}

std::ostream&
operator<<(std::ostream& os, const cookie_jar& cj)
{
Expand Down
3 changes: 3 additions & 0 deletions example/client/burl/cookie.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class cookie_jar
std::string
make_field(const urls::url_view& url);

void
clear_session_cookies();

friend
std::ostream&
operator<<(std::ostream& os, const cookie_jar& cj);
Expand Down
4 changes: 4 additions & 0 deletions example/client/burl/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,7 @@ main(int argc, char* argv[])
"Pass custom header(s) to server")
("help,h", "produce help message")
("http1.0", "Use HTTP 1.0")
("junk-session-cookies,j", "Ignore session cookies read from file")
("location,L", "Follow redirects")
("output,o",
po::value<std::string>()->value_name("<file>"),
Expand Down Expand Up @@ -1412,6 +1413,9 @@ main(int argc, char* argv[])
}
}

if(vm.count("junk-session-cookies") && cookie_jar.has_value())
cookie_jar->clear_session_cookies();

asio::co_spawn(
ioc,
request(
Expand Down

0 comments on commit 02fe354

Please sign in to comment.