Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxy 的 onRequest 有沒有方法像 hook 一樣整個bypass? #118

Open
cyfung1031 opened this issue Aug 16, 2023 · 2 comments · May be fixed by #120
Open

proxy 的 onRequest 有沒有方法像 hook 一樣整個bypass? #118

cyfung1031 opened this issue Aug 16, 2023 · 2 comments · May be fixed by #120

Comments

@cyfung1031
Copy link
Contributor

hook有這個

  onreadystatechange:function(xhr,event){
    console.log("onreadystatechange called: %O")
    //返回false表示不阻断,拦截函数执行完后会接着执行真正的xhr.onreadystatechange回调.
    //返回true则表示阻断,拦截函数执行完后将不会执行xhr.onreadystatechange. 
    return false
  },

如果我想在proxy中onRequest像上面一個整個bypass不進入任何onResponse onError, 有方法嗎
(連handler.next(config)都不跑,直接原生較快也不會對我不處理的request出現bug)

ah.proxy({
            onRequest: (config, handler) => {
                 if(config.url == 'xxxxxxxx'){
                        // handler.bypass()??
                  }
                  // handler.next(config)
            },
             ...
})
@DAHUIAAAAA
Copy link
Collaborator

不调用 handler.next 就可以,只有调用了之后,才会真正调用 open 和 send 方法,下面这个是 next 方法
image

@cyfung1031
Copy link
Contributor Author

不调用 handler.next 就可以,只有调用了之后,才会真正调用 open 和 send 方法,下面这个是 next 方法 image

你誤會了
現在機制是 ah 把整個hack了然後交給裡面的onRequest onResponse處理
很多時因為bug或者是什麼,其實都不用把所有request都處理
不需要理會的網址直接交回原生的處理就好
現在只能透過onRequest onResponse裡面都設一個handler.next

我意思是,在open 的階段,做一個onConfig, 可以直接濾掉不需理會的網址
(onRequest做不到原因是大多數都是async=true)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants