1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| request : function(options) { options = options || {}; var me = this, scope = options.scope || window, username = options.username || me.username, password = options.password || me.password || '', async, requestOptions, request, headers, xhr; if (me.fireEvent('beforerequest', me, options) !== false) {
requestOptions = me.setOptions(options, scope);
if (me.isFormUpload(options)) { me.upload(options.form, requestOptions.url, requestOptions.data, options); return null; }
if (options.autoAbort || me.autoAbort) { me.abort(); }
async = options.async !== false ? (options.async || me.async) : false; xhr = me.openRequest(options, requestOptions, async, username, password);
if (!me.isXdr) { headers = me.setupHeaders(xhr, options, requestOptions.data, requestOptions.params); }
request = { id: ++Ext.data.Connection.requestId, xhr: xhr, headers: headers, options: options, async: async, binary: options.binary || me.binary, timeout: setTimeout(function() { request.timedout = true; me.abort(request); }, options.timeout || me.timeout) };
me.requests[request.id] = request; me.latestId = request.id;
if (async) { if (!me.isXdr) { xhr.onreadystatechange = Ext.Function.bind(me.onStateChange, me, [request]); } }
if (me.isXdr) { me.processXdrRequest(request, xhr); }
xhr.send(requestOptions.data); if (!async) { return me.onComplete(request); } return request; } else { Ext.callback(options.callback, options.scope, [options, undefined, undefined]); return null; } },
|