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 @@ -480,6 +480,14 @@ class request
480480 m_debug_info_handler = std::move (callback_functor);
481481 }
482482
483+ /* *
484+ * @param cookie_file The filename to read cookies from;
485+ * empty string ("") enables the cookie engine without reading any initial cookies;
486+ * "-" (a single minus sign) reads from stdin instead;
487+ * std::nullopt disables the cookie engine and clears the list of files to read cookies from.
488+ */
489+ auto cookie_file (std::optional<std::filesystem::path> cookie_file) -> void { m_cookie_file = cookie_file; }
490+
483491private:
484492 // / The on complete handler callback or promise to fulfill, this is only used for async requests.
485493 impl::copy_but_actually_move<async_handlers_type> m_on_complete_handler{std::monostate{}};
@@ -535,6 +543,8 @@ class request
535543 std::optional<std::chrono::milliseconds> m_happy_eyeballs_timeout{};
536544 // / The debug callback functor for `debug_info_type` information. If nullptr will not be set.
537545 debug_info_callback_type m_debug_info_handler{nullptr };
546+ // The filename to read cookies from.
547+ std::optional<std::filesystem::path> m_cookie_file;
538548
539549 /* *
540550 * 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 @@ -393,6 +393,9 @@ auto executor::prepare() -> void
393393
394394 m_response.m_network_error_message [0 ] = ' \0 ' ;
395395 curl_easy_setopt (m_curl_handle, CURLOPT_ERRORBUFFER, m_response.m_network_error_message );
396+ // https://curl.se/libcurl/c/CURLOPT_COOKIEFILE.html
397+ curl_easy_setopt (
398+ m_curl_handle, CURLOPT_COOKIEFILE, m_request->m_cookie_file ? m_request->m_cookie_file ->string ().c_str () : nullptr );
396399}
397400
398401auto executor::copy_curl_to_response (CURLcode curl_code) -> void
You can’t perform that action at this time.
0 commit comments