File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ interface XhrErrorHandler extends XhrHandler {
9797}
9898
9999interface Proxy {
100+ onConfig ?: ( config : XhrRequestConfig , xhrProxy : Hooks ) => boolean | void ,
100101 onRequest ?: ( config : XhrRequestConfig , handler : XhrRequestHandler ) => void ,
101102 onResponse ?: ( response : XhrResponse , handler : XhrResponseHandler ) => void ,
102103 onError ?: ( err : XhrError , handler : XhrErrorHandler ) => void ,
Original file line number Diff line number Diff line change @@ -102,7 +102,9 @@ var ErrorHandler = makeHandler(function (error) {
102102} ) ;
103103
104104function proxyAjax ( proxy , win ) {
105- var onRequest = proxy . onRequest ,
105+ var onConfig = proxy . onConfig ,
106+ onRequest = null ,
107+ onRequest_ = proxy . onRequest ,
106108 onResponse = proxy . onResponse ,
107109 onError = proxy . onError ;
108110
@@ -187,6 +189,10 @@ function proxyAjax(proxy, win) {
187189 // 所以我们在send拦截函数中再手动调用open,因此返回true阻止xhr.open调用。
188190 //
189191 // 如果没有请求拦截器,则不用阻断xhr.open调用
192+ onRequest = onRequest_ ;
193+ if ( onConfig ) {
194+ if ( onConfig ( config , this ) === false ) onRequest = null
195+ }
190196 if ( onRequest ) return true ;
191197 } ,
192198 send : function ( args , xhr ) {
You can’t perform that action at this time.
0 commit comments