MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / ReadCookieFile

Method ReadCookieFile

cpp/iedriver/CookieManager.cpp:286–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286std::string CookieManager::ReadCookieFile(const std::wstring& file_name) {
287 LOG(TRACE) << "Entering CookieManager::ReadCookieFile";
288 HANDLE file_handle = ::CreateFile(file_name.c_str(),
289 GENERIC_READ,
290 FILE_SHARE_READ | FILE_SHARE_WRITE,
291 NULL,
292 OPEN_EXISTING,
293 0,
294 NULL);
295 // Read the cookie file. Hopefully, we will never have a 2GB cookie file.
296 DWORD file_size_high = 0;
297 DWORD file_size_low = ::GetFileSize(file_handle, &file_size_high);
298 std::vector<char> file_content(file_size_low + 1);
299 DWORD bytes_read = 0;
300 ::ReadFile(file_handle, &file_content[0], file_size_low, &bytes_read, NULL);
301 ::CloseHandle(file_handle);
302
303 // Null-terminate and convert to a string for easier manipulation.
304 file_content[bytes_read - 1] = '\0';
305 std::string cookie_file_contents = &file_content[0];
306 return cookie_file_contents;
307}
308
309void CookieManager::ParseCookieList(const std::string& cookie_file_contents,
310 const bool include_secure_cookies,

Callers 1

GetCookiesMethod · 0.95

Calls 1

LOGClass · 0.50

Tested by

no test coverage detected