Значение куки не распространяется в QWebEngineView - PullRequest
0 голосов
/ 21 мая 2019

Я пытаюсь открыть файл jsp, используя QWebEngineView, используя QWebEngineProfile, QWebEnginePage и QWebEngineCookieStore.Я могу установить cookie для своего звонка, который я инициировал из своего приложения.Но затем позднее инициируются несколько вызовов jsp, но для этого вызова не устанавливается cookie.Код снип-это как ниже.

QWebEngineSettings* webEngineSettings = QWebEngineSettings::defaultSettings();                webEngineSettings->setAttribute(QWebEngineSettings::WebAttribute::AutoLoadImages, true);        webEngineSettings->setAttribute(QWebEngineSettings::WebAttribute::JavascriptEnabled, true);                         webEngineSettings->setAttribute(QWebEngineSettings::WebAttribute::LocalStorageEnabled, true);

QWebEngineProfile* profile = new QWebEngineProfile("abc", parent);
profile->setPersistentCookiesPolicy(QWebEngineProfile::AllowPersistentCookies);
profile->setHttpCacheType(QWebEngineProfile::HttpCacheType::MemoryHttpCache);
profile->setHttpCacheMaximumSize(10);
QWebEngineCookieStore* cookieStore = profile->cookieStore();
cookieStore->loadAllCookies();
QNetworkCookie* webEngineNewCookie = new NetworkCookie(QByteArray("MyCookie"), QByteArray("1234"));
QUrl url = "https://example.com/help.jsp"
cookieStore->setCookie(*webEngineNewCookie, QUrl(url));
QStringList location = QStandardPaths::standardLocations(QStandardPaths::CacheLocation);
profile->setPersistentStoragePath(location.at(0));

QWebEnginePage* page = new QWebEnginePage(profile,parent);
page->action(QWebEnginePage::WebAction::InspectElement);

QWebEngineHttpRequest* webEngineHttpReq = new QWebEngineHttpRequest(QUrl(url), QWebEngineHttpRequest::Post);
parent->setPage(page);
parent->load(*webEngineHttpReq);

Когда я делаю этот вызов, я получаю cookie в этом (https://example.com/help.jsp), но после этого из help.jsp инициируются другие вызовы, эти звонки не могут содержать файлы cookieпоэтому они заблокированы сервером.

...