Hi all,In Electron we expose a module that is a wrapper around SimpleURLLoader for making net requests in Nodejs style , pre network service this used to be a wrapper around net::URLRequest and the net::URLRequest::Delegate class provided all the required callbacks for various phases of a request lifecycle.With network service, the auth handling is delegated to the network service client , in the content layer case this is done by StoragepartitionImpl which checks for a valid webcontents associated with the auth request through the network interceptors (like devtools and service workers) to create the LoginHandlerDelegate and noops in other scenarios.The idea of the above module in electron is to make requests without any associated webcontents.Ideally this can be solved on our end by creating a custom network service client for the network context used by that module but we allow users to reuse the network context which comes from the storage partitions associated with their app so that other setting like proxy take effect automatically for this module and since there can be only one network client with a context, this path is a no-go for us.
which brings me to the question , would it make sense to add a SetOnAuthRequiredCallback to the SimpleURLLoader class for this use case ?
--
You received this message because you are subscribed to the Google Groups "Chromium Embedders" group.
To unsubscribe from this group and stop receiving emails from it, send an email to embedder-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/embedder-dev/5c25670a-2e23-480b-a7a3-198850c20549%40chromium.org.
// session is javascript wrapper around content::BrowserContext and its associated NetworkContext
// net is a wrapper around SimpleURLLoader
const {session, net} = require('electron')
const customSession = session.fromPartition('persist:abc') // can also create in memory version if needed
customSession.setProxy('something') // sets the proxy for this custom NetworkContext
const request = net.request({
url: 'https://example.com',
session: customSession
})
request.on('response', (res) => {
// all sorts of magic
})
request.on('login', (authInfo, callback) => {
// get auth creds
})
request.end()
// new version
const request = net.request({
url: 'https://example.com'
})
request.session.setProxy('something') // allow customization on session
request.on('response', (res) => {
// all sorts of magic
})
request.on('login', (authInfo, callback) => {
// get auth creds
})
request.end()
To unsubscribe from this group and stop receiving emails from it, send an email to embedd...@chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium Embedders" group.
To unsubscribe from this group and stop receiving emails from it, send an email to embedder-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/embedder-dev/8799d567-1376-474b-beea-b4ac43edb2fe%40chromium.org.
Sorry if I didn't explain it clearly in https://groups.google.com/a/chromium.org/d/msg/embedder-dev/du2PveLOZXY/S6QkDv4uAAAJ , yes electron can customize any network context. But we want to reuse the network context from the storage partition, as we maintain a 1:1 mapping between BrowserContext -> StoragePartition -> NetworkContext.Every session in electron has only one BrowserContext associated with it, which adheres to the above mapping. And users can reuse this session for multiple webContents as well as this net module, so not sure how bringing in a new custom network context would solve this use case ?
--
You received this message because you are subscribed to the Google Groups "Chromium Embedders" group.
To unsubscribe from this group and stop receiving emails from it, send an email to embedder-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/embedder-dev/8871f7de-3e6b-45db-9efa-d2130015af8a%40chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/embedder-dev/CALhVsw10KAEq6AFXEP6wGw6%3D%3DB_46J_1oxnY7xYooV9cox4g7Q%40mail.gmail.com.