Skip to content

Commit

Permalink
wasm: allow useCredentials access control to be set
Browse files Browse the repository at this point in the history
Introduce UseCredentialsAttribute that indicates whether
the underlying fetch/XMLHttpRequest should use credentials
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials

Fixes: QTBUG-90893
Change-Id: I2c43e286db52df387c0a22737d027b9a2a8dd2d3
Reviewed-by: Mårten Nordheim <[email protected]>
  • Loading branch information
lpotter committed Sep 28, 2022
1 parent 77646f6 commit 2efd2f4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/network/access/qnetworkreplywasmimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ void QNetworkReplyWasmImplPrivate::doSendRequest()
request.attribute(QNetworkRequest::CacheSaveControlAttribute, false).toBool()) {
attr.attributes -= EMSCRIPTEN_FETCH_PERSIST_FILE;
}
if (request.attribute(QNetworkRequest::UseCredentialsAttribute, true).toBool()) {
attr.withCredentials = true;
}

attr.onsuccess = QNetworkReplyWasmImplPrivate::downloadSucceeded;
attr.onerror = QNetworkReplyWasmImplPrivate::downloadFailed;
Expand Down
7 changes: 7 additions & 0 deletions src/network/access/qnetworkrequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,13 @@ QT_IMPL_METATYPE_EXTERN_TAGGED(QNetworkRequest::RedirectPolicy, QNetworkRequest_
This attribute is ignored if the Http2AllowedAttribute is not set.
(This value was introduced in 6.3.)
\value UseCredentialsAttribute
Requests only, type: QMetaType::Bool (default: false)
Indicates if the underlying XMLHttpRequest cross-site Access-Control
requests should be made using credentials. Has no effect on
same-origin requests. This only affects the WebAssembly platform.
(This value was introduced in 6.5.)
\value User
Special type. Additional information can be passed in
QVariants with types ranging from User to UserMax. The default
Expand Down
1 change: 1 addition & 0 deletions src/network/access/qnetworkrequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Q_NETWORK_EXPORT QNetworkRequest
AutoDeleteReplyOnFinishAttribute,
ConnectionCacheExpiryTimeoutSecondsAttribute,
Http2CleartextAllowedAttribute,
UseCredentialsAttribute,

User = 1000,
UserMax = 32767
Expand Down

0 comments on commit 2efd2f4

Please sign in to comment.