久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

我們?nèi)绾尾拍苤皇褂锰囟窂降?electron.protocol.

How can we use electron.protocol.interceptFileProtocol with only certain paths, leaving other requests untouched?(我們?nèi)绾尾拍苤皇褂锰囟窂降?electron.protocol.interceptFileProtocol ,而不影響其他請(qǐng)求?) - IT屋-程序員
本文介紹了我們?nèi)绾尾拍苤皇褂锰囟窂降?electron.protocol.interceptFileProtocol ,而不影響其他請(qǐng)求?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我想攔截某些 HTTP 請(qǐng)求并將它們替換為文件.所以我想我可以像這樣使用 electron.protocol.interceptFileProtocol :

I'd like to intercept certain HTTP requests and replace them with files. So I thought I could use electron.protocol.interceptFileProtocol like so:

protocol.interceptFileProtocol('http', (request, callback) => {
  // intercept only requests to "http://example.com"
  if (request.url.startsWith("http://example.com")) {
    callback("/path/to/file")
  }

  // otherwise, let the HTTP request behave like normal.
  // But how?
})

我們?nèi)绾卧试S除 http://example.com 之外的其他 http 請(qǐng)求繼續(xù)正常工作?

How do we allow other http requests other than http://example.com to continue working as normal?

推薦答案

在使用 protocol.interceptXXXXProtocol(scheme, handler) 時(shí),我們正在攔截方案協(xié)議,并使用 handler 作為協(xié)議的新處理程序,發(fā)送一個(gè)新的 XXXX 請(qǐng)求作為響應(yīng),如 在此處的文檔中所述.

When using protocol.interceptXXXXProtocol(scheme, handler), we are intercepting scheme protocol and uses handler as the protocol’s new handler which sends a new XXXX request as a response, as said in the doc here.

但是,這樣做完全破壞了這個(gè)特定協(xié)議的初始處理程序,我們?cè)谔幚砘卣{(diào)執(zhí)行后需要它.因此,我們只需要將它恢復(fù)到初始狀態(tài),它就可以繼續(xù)正常工作:)

However, doing so totally breaks the initial handler for this specific protocol, which we would need after handling the callback execution. Thus, we just need to restore it back to its initial state, so that it can continue working as normal :)

讓我們使用:protocol.uninterceptProptocol(scheme)

protocol.interceptFileProtocol('http', (request, callback) => {
  // intercept only requests to "http://example.com"
  if (request.url.startsWith("http://example.com")) {
    callback("/path/to/file")
  }

  // otherwise, let the HTTP request behave like normal.
  protocol.uninterceptProtocol('http');
})

這篇關(guān)于我們?nèi)绾尾拍苤皇褂锰囟窂降?electron.protocol.interceptFileProtocol ,而不影響其他請(qǐng)求?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進(jìn)程中創(chuàng)建子窗口時(shí)如何修復(fù) BrowserWindow 不是構(gòu)造函數(shù)錯(cuò)誤) - IT屋-程序員軟件開(kāi)發(fā)技術(shù)
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應(yīng)用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無(wú)法在第二個(gè) loadURL 上執(zhí)行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內(nèi)使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲(chǔ)?)
How to access camera/webcamera inside electron app?(如何在電子應(yīng)用程序中訪問(wèn)相機(jī)/網(wǎng)絡(luò)攝像頭?)
主站蜘蛛池模板: 久久精品视频国产 | 亚洲区在线 | 国产一区在线视频 | 艳妇诱春(第5部分)(h) | 91成人国产 | 日韩影音 | 操综合| 欧美成人精品一区二区三区在线看 | 成人高清在线 | 国产美女91呻吟求 | 亚洲一区三区 | 黑人精品一区二区 | 中文字幕免费视频 | 成人在线免费看 | 国产一区二区精品丝袜 | 国产精品手机在线 | 黄色片免费 | 天堂va蜜桃一区二区三区 | 国产一级片视频 | 在线观看免费av网站 | 中文字幕在线免费看 | 日韩在线精品视频 | 九九九精品视频 | 日韩在线网址 | 欧美视频在线播放 | 日韩不卡在线观看 | 四虎在线视频 | 91手机在线视频 | 91免费国产 | 成人av网站在线观看 | 精品国产乱码久久久久久88av | 成人黄色免费视频 | 亚洲视频在线看 | 亚洲国产精品久久久 | 手机看片国产 | 黄网免费观看 | 中文字幕欧美激情 | 国产黄网 | 可以看av的网站 | 中文在线观看免费网站 | 91免费看片网站 |