MCPcopy Create free account
hub / github.com/ZToolsCenter/ZTools / removeRequestInterceptor

Method removeRequestInterceptor

src/main/api/plugin/http.ts:179–197  ·  view source on GitHub ↗

* 移除请求拦截器

(runtimeNamespace: string, sess: Electron.Session)

Source from the content-addressed store, hash-verified

177 * 移除请求拦截器
178 */
179 private removeRequestInterceptor(runtimeNamespace: string, sess: Electron.Session): void {
180 const listener = this.interceptors.get(runtimeNamespace)
181 if (listener) {
182 try {
183 // 通过传递 null 作为 listener 来移除该监听器
184 // 注意:这会移除该 session 的所有 onBeforeSendHeaders 监听器
185 // 但由于每个插件都有独立的 session,这不会影响其他插件
186 sess.webRequest.onBeforeSendHeaders(
187 {
188 urls: ['http://*/*', 'https://*/*']
189 },
190 null as any
191 )
192 this.interceptors.delete(runtimeNamespace)
193 } catch (error) {
194 console.warn('[PluginHttp] 移除请求拦截器失败:', error)
195 }
196 }
197 }
198
199 /**
200 * 清理插件数据(当插件卸载时调用)

Callers 2

setupIPCMethod · 0.95
cleanupPluginMethod · 0.95

Calls 1

getMethod · 0.65

Tested by

no test coverage detected