File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -472,6 +472,14 @@ class request
472472 m_debug_info_handler = std::move (callback_functor);
473473 }
474474
475+ /* *
476+ * @param cookie_file The filename to read cookies from;
477+ * empty string ("") enables the cookie engine without reading any initial cookies;
478+ * "-" (a single minus sign) reads from stdin instead;
479+ * std::nullopt disables the cookie engine and clears the list of files to read cookies from.
480+ */
481+ auto cookie_file (std::optional<std::filesystem::path> cookie_file) -> void { m_cookie_file = cookie_file; }
482+
475483private:
476484 // / The on complete handler callback or promise to fulfill, this is only used for async requests.
477485 impl::copy_but_actually_move<async_handlers_type> m_on_complete_handler{std::monostate{}};
@@ -525,6 +533,8 @@ class request
525533 std::optional<std::chrono::milliseconds> m_happy_eyeballs_timeout{};
526534 // / The debug callback functor for `debug_info_type` information. If nullptr will not be set.
527535 debug_info_callback_type m_debug_info_handler{nullptr };
536+ // The filename to read cookies from.
537+ std::optional<std::filesystem::path> m_cookie_file;
528538
529539 /* *
530540 * Used by the client to set an async callback for on completion notification to the user.
Original file line number Diff line number Diff line change @@ -398,6 +398,9 @@ auto executor::prepare() -> void
398398 curl_easy_setopt (m_curl_handle, CURLOPT_DEBUGFUNCTION, curl_debug_info_callback);
399399 curl_easy_setopt (m_curl_handle, CURLOPT_DEBUGDATA, this );
400400 }
401+ // https://curl.se/libcurl/c/CURLOPT_COOKIEFILE.html
402+ curl_easy_setopt (
403+ m_curl_handle, CURLOPT_COOKIEFILE, m_request->m_cookie_file ? m_request->m_cookie_file ->string ().c_str () : nullptr );
401404}
402405
403406auto executor::copy_curl_to_response () -> void
You can’t perform that action at this time.
0 commit comments