File tree 2 files changed +8
-1
lines changed
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 {
97
97
}
98
98
99
99
interface Proxy {
100
+ onConfig ?: ( config : XhrRequestConfig , xhrProxy : Hooks ) => boolean | void ,
100
101
onRequest ?: ( config : XhrRequestConfig , handler : XhrRequestHandler ) => void ,
101
102
onResponse ?: ( response : XhrResponse , handler : XhrResponseHandler ) => void ,
102
103
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) {
102
102
} ) ;
103
103
104
104
function proxyAjax ( proxy , win ) {
105
- var onRequest = proxy . onRequest ,
105
+ var onConfig = proxy . onConfig ,
106
+ onRequest = null ,
107
+ onRequest_ = proxy . onRequest ,
106
108
onResponse = proxy . onResponse ,
107
109
onError = proxy . onError ;
108
110
@@ -187,6 +189,10 @@ function proxyAjax(proxy, win) {
187
189
// 所以我们在send拦截函数中再手动调用open,因此返回true阻止xhr.open调用。
188
190
//
189
191
// 如果没有请求拦截器,则不用阻断xhr.open调用
192
+ onRequest = onRequest_ ;
193
+ if ( onConfig ) {
194
+ if ( onConfig ( config , this ) === false ) onRequest = null ;
195
+ }
190
196
if ( onRequest ) return true ;
191
197
} ,
192
198
send : function ( args , xhr ) {
You can’t perform that action at this time.
0 commit comments