3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
17 * @class Ext.ux.ajax.SimXhr
19 * Simulates an XMLHttpRequest object's methods and properties but is backed by a
20 * {@link Simlet} instance that provides the data.
22 Ext.define('Ext.ux.ajax.SimXhr', {
28 constructor: function (config) {
31 Ext.apply(me, config);
32 me.requestHeaders = {};
39 clearTimeout(me.timer);
45 getAllResponseHeaders: function () {
47 Ext.Object.each(this.responseHeaders, function (name, value) {
48 headers.push(name + ': ' + value);
50 return headers.join('\x0d\x0a');
53 getResponseHeader: function (header) {
54 var headers = this.responseHeaders;
55 return (headers && headers[header]) || null;
58 open: function (method, url, async, user, password) {
62 me.async = async !== false;
64 me.password = password;
69 overrideMimeType: function (mimeType) {
70 this.mimeType = mimeType;
73 schedule: function () {
75 me.timer = setTimeout(function () {
80 send: function (body) {
92 setReadyState: function (state) {
94 if (me.readyState != state) {
95 me.readyState = state;
96 me.onreadystatechange();
100 setRequestHeader: function (header, value) {
101 this.requestHeaders[header] = value;
106 onreadystatechange: Ext.emptyFn,
108 onComplete: function () {
112 Ext.apply(me, me.simlet.exec(me));
115 onTick: function () {
120 me.onreadystatechange();