@qooxdoo/framework 7.0.0-beta.3 → 7.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/Manifest.json +1 -1
  3. package/README.md +9 -3
  4. package/lib/compiler/compile-info.json +60 -58
  5. package/lib/compiler/index.js +3242 -1883
  6. package/lib/resource/qx/tool/cli/templates/skeleton/mobile/source/theme/custom/css/custom.css.map +1 -1
  7. package/lib/resource/qx/tool/loadsass.js +6 -4
  8. package/lib/resource/qx/tool/schema/compile-1-0-0.json +6 -11
  9. package/package.json +17 -3
  10. package/source/class/qx/Bootstrap.js +22 -1
  11. package/source/class/qx/bom/Blocker.js +2 -1
  12. package/source/class/qx/core/Environment.js +3 -12
  13. package/source/class/qx/core/MProperty.js +1 -1
  14. package/source/class/qx/dev/unit/Sinon.js +1 -1
  15. package/source/class/qx/io/__init__.js +5 -3
  16. package/source/class/qx/io/exception/Cancel.js +34 -0
  17. package/source/class/qx/io/exception/Exception.js +38 -0
  18. package/source/class/qx/io/exception/Protocol.js +26 -0
  19. package/source/class/qx/io/exception/Transport.js +39 -0
  20. package/source/class/qx/io/exception/__init__.js +4 -0
  21. package/source/class/qx/io/graphql/Client.js +112 -0
  22. package/source/class/qx/io/graphql/__init__.js +9 -0
  23. package/source/class/qx/io/graphql/protocol/Message.js +65 -0
  24. package/source/class/qx/io/graphql/protocol/Request.js +95 -0
  25. package/source/class/qx/io/graphql/protocol/Response.js +61 -0
  26. package/source/class/qx/io/graphql/protocol/__init__.js +6 -0
  27. package/source/class/qx/io/jsonrpc/Client.js +323 -0
  28. package/source/class/qx/io/jsonrpc/__init__.js +15 -0
  29. package/source/class/qx/io/jsonrpc/protocol/Batch.js +97 -0
  30. package/source/class/qx/io/jsonrpc/protocol/Error.js +63 -0
  31. package/source/class/qx/io/jsonrpc/protocol/Message.js +48 -0
  32. package/source/class/qx/io/jsonrpc/protocol/Notification.js +45 -0
  33. package/source/class/qx/io/jsonrpc/protocol/Parser.js +81 -0
  34. package/source/class/qx/io/jsonrpc/protocol/Request.js +93 -0
  35. package/source/class/qx/io/jsonrpc/protocol/Result.js +48 -0
  36. package/source/class/qx/io/jsonrpc/protocol/__init__.js +5 -0
  37. package/source/class/qx/io/request/authentication/Bearer.js +52 -0
  38. package/source/class/qx/io/transport/AbstractClient.js +100 -0
  39. package/source/class/qx/io/transport/AbstractTransport.js +41 -0
  40. package/source/class/qx/io/transport/Fetch.js +95 -0
  41. package/source/class/qx/io/transport/ITransport.js +40 -0
  42. package/source/class/qx/io/transport/PostMessage.js +55 -0
  43. package/source/class/qx/io/transport/Websocket.js +97 -0
  44. package/source/class/qx/io/transport/Xhr.js +139 -0
  45. package/source/class/qx/io/transport/__init__.js +18 -0
  46. package/source/class/qx/test/core/Assert.js +1 -1
  47. package/source/class/qx/test/core/Environment.js +0 -3
  48. package/source/class/qx/test/io/MAssert.js +46 -0
  49. package/source/class/qx/test/io/graphql/Client.js +169 -0
  50. package/source/class/qx/test/io/graphql/ClientFetch.js +34 -0
  51. package/source/class/qx/test/io/graphql/Request.js +42 -0
  52. package/source/class/qx/test/io/jsonrpc/Client.js +267 -0
  53. package/source/class/qx/test/io/jsonrpc/Protocol.js +80 -0
  54. package/source/class/qx/test/io/transport/PostMessage.js +56 -0
  55. package/source/class/qx/test/io/transport/Websocket.js +63 -0
  56. package/source/class/qx/test/ui/embed/Iframe.js +1 -1
  57. package/source/class/qx/test/util/DateFormat.js +45 -6
  58. package/source/class/qx/tool/cli/Cli.js +1 -0
  59. package/source/class/qx/tool/cli/commands/Compile.js +13 -3
  60. package/source/class/qx/tool/cli/commands/Es6ify.js +93 -0
  61. package/source/class/qx/tool/cli/commands/package/Install.js +1 -1
  62. package/source/class/qx/tool/cli/commands/package/Publish.js +14 -0
  63. package/source/class/qx/tool/compiler/ClassFile.js +67 -27
  64. package/source/class/qx/tool/compiler/Es6ify.js +368 -0
  65. package/source/class/qx/tool/compiler/makers/AppMaker.js +2 -1
  66. package/source/class/qx/tool/compiler/targets/Target.js +57 -47
  67. package/source/class/qx/tool/compiler/targets/meta/AbstractJavascriptMeta.js +25 -18
  68. package/source/class/qx/tool/compiler/targets/meta/BootJs.js +16 -16
  69. package/source/class/qx/tool/compiler/targets/meta/PolyfillJs.js +11 -3
  70. package/source/class/qx/tool/compiler/targets/meta/Uglify.js +10 -10
  71. package/source/class/qx/ui/core/Widget.js +70 -0
  72. package/source/class/qx/ui/decoration/MLinearBackgroundGradient.js +2 -1
  73. package/source/class/qx/ui/form/ComboBox.js +8 -3
  74. package/source/class/qx/ui/form/DateField.js +16 -1
  75. package/source/class/qx/ui/form/MenuButton.js +8 -4
  76. package/source/class/qx/ui/form/SelectBox.js +8 -3
  77. package/source/class/qx/ui/menu/AbstractButton.js +12 -8
  78. package/source/class/qx/ui/menu/Menu.js +18 -8
  79. package/source/class/qx/ui/table/pane/Model.js +10 -4
  80. package/source/class/qx/ui/window/Window.js +8 -0
  81. package/source/class/qx/util/format/DateFormat.js +44 -17
  82. package/source/resource/qx/tool/loadsass.js +6 -4
  83. package/source/resource/qx/tool/schema/compile-1-0-0.json +6 -11
  84. package/source/translation/hr.po +297 -0
  85. package/lib/resource/qx/static/blank.gif +0 -0
  86. package/source/class/qx/io/remote/Exchange.js +0 -1063
  87. package/source/class/qx/io/remote/Request.js +0 -1021
  88. package/source/class/qx/io/remote/RequestQueue.js +0 -521
  89. package/source/class/qx/io/remote/Response.js +0 -137
  90. package/source/class/qx/io/remote/Rpc.js +0 -1075
  91. package/source/class/qx/io/remote/RpcError.js +0 -198
  92. package/source/class/qx/io/remote/__init__.js +0 -88
  93. package/source/class/qx/io/remote/transport/Abstract.js +0 -513
  94. package/source/class/qx/io/remote/transport/Iframe.js +0 -652
  95. package/source/class/qx/io/remote/transport/Script.js +0 -475
  96. package/source/class/qx/io/remote/transport/XmlHttp.js +0 -1019
  97. package/source/class/qx/io/remote/transport/__init__.js +0 -3
  98. package/source/class/qx/test/io/remote/AbstractRequest.js +0 -150
  99. package/source/class/qx/test/io/remote/RequestIframe.js +0 -105
  100. package/source/class/qx/test/io/remote/RequestXhr.js +0 -151
  101. package/source/class/qx/test/io/remote/Rpc.js +0 -205
  102. package/source/class/qx/test/io/remote/__init__.js +0 -4
  103. package/source/class/qx/test/io/remote/transport/Iframe.js +0 -67
  104. package/source/class/qx/test/io/remote/transport/XmlHttp.js +0 -133
  105. package/source/class/qx/test/io/remote/transport/__init__.js +0 -4
@@ -1,1019 +0,0 @@
1
- /* ************************************************************************
2
-
3
- qooxdoo - the new era of web development
4
-
5
- http://qooxdoo.org
6
-
7
- Copyright:
8
- 2004-2008 1&1 Internet AG, Germany, http://www.1und1.de
9
- 2006 Derrell Lipman
10
-
11
- License:
12
- MIT: https://opensource.org/licenses/MIT
13
- See the LICENSE file in the project's top-level directory for details.
14
-
15
- Authors:
16
- * Sebastian Werner (wpbasti)
17
- * Andreas Ecker (ecker)
18
- * Derrell Lipman (derrell)
19
-
20
- ************************************************************************ */
21
-
22
- /**
23
- * Transports requests to a server using the native XmlHttpRequest object.
24
- *
25
- * This class should not be used directly by client programmers.
26
- */
27
-
28
- qx.Class.define("qx.io.remote.transport.XmlHttp",
29
- {
30
- extend : qx.io.remote.transport.Abstract,
31
- implement: [ qx.core.IDisposable ],
32
-
33
-
34
- /*
35
- *****************************************************************************
36
- STATICS
37
- *****************************************************************************
38
- */
39
-
40
- statics :
41
- {
42
- /**
43
- * Capabilities of this transport type.
44
- *
45
- * @internal
46
- */
47
- handles :
48
- {
49
- synchronous : true,
50
- asynchronous : true,
51
- crossDomain : false,
52
- fileUpload : false,
53
- programmaticFormFields : false,
54
- responseTypes : [ "text/plain", "text/javascript", "application/json", "application/xml", "text/html" ]
55
- },
56
-
57
-
58
- /**
59
- * Return a new XMLHttpRequest object suitable for the client browser.
60
- *
61
- * @return {Object} native XMLHttpRequest object
62
- * @signature function()
63
- *
64
- * @ignore(XMLHttpRequest)
65
- */
66
- createRequestObject : qx.core.Environment.select("engine.name",
67
- {
68
- "default" : function() {
69
- return new XMLHttpRequest;
70
- },
71
-
72
- // IE7's native XmlHttp does not care about trusted zones. To make this
73
- // work in the localhost scenario, you can use the following registry setting:
74
- //
75
- // [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\
76
- // FeatureControl\FEATURE_XMLHTTP_RESPECT_ZONEPOLICY]
77
- // "Iexplore.exe"=dword:00000001
78
- //
79
- // Generally it seems that the ActiveXObject is more stable. jQuery
80
- // seems to use it always. We prefer the ActiveXObject for the moment, but allow
81
- // fallback to XMLHTTP if ActiveX is disabled.
82
- "mshtml" : function()
83
- {
84
- if (window.ActiveXObject && qx.xml.Document.XMLHTTP) {
85
- return new window.ActiveXObject(qx.xml.Document.XMLHTTP);
86
- }
87
-
88
- if (window.XMLHttpRequest) {
89
- return new window.XMLHttpRequest;
90
- }
91
- }
92
- }),
93
-
94
-
95
- /**
96
- * Whether the transport type is supported by the client.
97
- *
98
- * @return {Boolean} supported or not
99
- */
100
- isSupported : function() {
101
- return !!this.createRequestObject();
102
- },
103
-
104
-
105
- /** The timeout for Xhr requests */
106
- __timeout: 0,
107
-
108
-
109
- /**
110
- * Sets the timeout for requests
111
- * @deprecated {6.0} This method is deprecated from the start because synchronous I/O itself is deprecated
112
- * in the W3C spec {@link https://xhr.spec.whatwg.org/} and timeouts are indicative of synchronous I/O and/or
113
- * other server issues. However, this API is still supported by many browsers and this API is useful
114
- * for code which has not made the transition to asynchronous I/O
115
- */
116
- setTimeout: function(timeout) {
117
- this.__timeout = timeout;
118
- },
119
-
120
-
121
- /**
122
- * Returns the timeout for requests
123
- */
124
- getTimeout: function() {
125
- return this.__timeout;
126
- }
127
- },
128
-
129
-
130
- /*
131
- *****************************************************************************
132
- PROPERTIES
133
- *****************************************************************************
134
- */
135
-
136
- properties :
137
- {
138
- /**
139
- * If true and the responseType property is set to "application/json", getResponseContent() will
140
- * return a Javascript map containing the JSON contents, i. e. the result qx.lang.Json.parse().
141
- * If false, the raw string data will be returned and the parsing must be done manually.
142
- * This is useful for special JSON dialects / extensions which are not supported by
143
- * qx.lang.Json.
144
- */
145
- parseJson :
146
- {
147
- check : "Boolean",
148
- init : true
149
- }
150
- },
151
-
152
-
153
- /*
154
- *****************************************************************************
155
- MEMBERS
156
- *****************************************************************************
157
- */
158
-
159
- members :
160
- {
161
- /*
162
- ---------------------------------------------------------------------------
163
- CORE METHODS
164
- ---------------------------------------------------------------------------
165
- */
166
-
167
- __localRequest : false,
168
- __lastReadyState : 0,
169
- __request : null,
170
-
171
-
172
- /**
173
- * Returns the native request object
174
- *
175
- * @return {Object} native XmlHTTPRequest object
176
- */
177
- getRequest : function()
178
- {
179
- if (this.__request === null)
180
- {
181
- this.__request = qx.io.remote.transport.XmlHttp.createRequestObject();
182
- this.__request.onreadystatechange = qx.lang.Function.bind(this._onreadystatechange, this);
183
- }
184
-
185
- return this.__request;
186
- },
187
-
188
-
189
-
190
-
191
- /*
192
- ---------------------------------------------------------------------------
193
- USER METHODS
194
- ---------------------------------------------------------------------------
195
- */
196
-
197
- /**
198
- * Implementation for sending the request
199
- *
200
- */
201
- send : function()
202
- {
203
- this.__lastReadyState = 0;
204
-
205
- var vRequest = this.getRequest();
206
- var vMethod = this.getMethod();
207
- var vAsynchronous = this.getAsynchronous();
208
- var vUrl = this.getUrl();
209
-
210
- // --------------------------------------
211
- // Local handling
212
- // --------------------------------------
213
- var vLocalRequest = (window.location.protocol === "file:" && !(/^http(s){0,1}\:/.test(vUrl)));
214
- this.__localRequest = vLocalRequest;
215
-
216
- // --------------------------------------
217
- // Adding URL parameters
218
- // --------------------------------------
219
- var vParameters = this.getParameters(false);
220
- var vParametersList = [];
221
-
222
- for (var vId in vParameters)
223
- {
224
- var value = vParameters[vId];
225
-
226
- if (value instanceof Array)
227
- {
228
- for (var i=0; i<value.length; i++) {
229
- vParametersList.push(encodeURIComponent(vId) + "=" + encodeURIComponent(value[i]));
230
- }
231
- }
232
- else
233
- {
234
- vParametersList.push(encodeURIComponent(vId) + "=" + encodeURIComponent(value));
235
- }
236
- }
237
-
238
- if (vParametersList.length > 0) {
239
- vUrl += (vUrl.indexOf("?") >= 0 ? "&" : "?") + vParametersList.join("&");
240
- }
241
-
242
- // --------------------------------------------------------
243
- // Adding data parameters (if no data is already present)
244
- // --------------------------------------------------------
245
- if (this.getData() === null)
246
- {
247
- var vParameters = this.getParameters(true);
248
- var vParametersList = [];
249
-
250
- for (var vId in vParameters)
251
- {
252
- var value = vParameters[vId];
253
-
254
- if (value instanceof Array)
255
- {
256
- for (var i=0; i<value.length; i++)
257
- {
258
- vParametersList.push(encodeURIComponent(vId) +
259
- "=" +
260
- encodeURIComponent(value[i]));
261
- }
262
- }
263
- else
264
- {
265
- vParametersList.push(encodeURIComponent(vId) +
266
- "=" +
267
- encodeURIComponent(value));
268
- }
269
- }
270
-
271
- if (vParametersList.length > 0)
272
- {
273
- this.setData(vParametersList.join("&"));
274
- }
275
- }
276
-
277
- var encode64 = function(input)
278
- {
279
- var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
280
- var output = "";
281
- var chr1, chr2, chr3;
282
- var enc1, enc2, enc3, enc4;
283
- var i = 0;
284
-
285
- do
286
- {
287
- chr1 = input.charCodeAt(i++);
288
- chr2 = input.charCodeAt(i++);
289
- chr3 = input.charCodeAt(i++);
290
-
291
- enc1 = chr1 >> 2;
292
- enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
293
- enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
294
- enc4 = chr3 & 63;
295
-
296
- if (isNaN(chr2)) {
297
- enc3 = enc4 = 64;
298
- } else if (isNaN(chr3)) {
299
- enc4 = 64;
300
- }
301
-
302
- output += keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);
303
- }
304
- while (i < input.length);
305
-
306
- return output;
307
- };
308
-
309
- // --------------------------------------
310
- // Opening connection
311
- // --------------------------------------
312
- try
313
- {
314
- if (this.getUsername())
315
- {
316
- if (this.getUseBasicHttpAuth())
317
- {
318
- vRequest.open(vMethod, vUrl, vAsynchronous);
319
- vRequest.setRequestHeader('Authorization', 'Basic ' + encode64(this.getUsername() + ':' + this.getPassword()));
320
- }
321
- else
322
- {
323
- vRequest.open(vMethod, vUrl, vAsynchronous, this.getUsername(), this.getPassword());
324
- }
325
- }
326
- else
327
- {
328
- vRequest.open(vMethod, vUrl, vAsynchronous);
329
- }
330
- }
331
- catch(ex)
332
- {
333
- this.error("Failed with exception: " + ex);
334
- this.failed();
335
- return;
336
- }
337
-
338
- // Apply timeout
339
- var timeout = qx.io.remote.transport.XmlHttp.getTimeout();
340
- if (timeout && vAsynchronous) {
341
- vRequest.timeout = timeout;
342
- }
343
-
344
- // --------------------------------------
345
- // Applying request header
346
- // --------------------------------------
347
- // Removed adding a referer header as this is not allowed anymore on most
348
- // browsers
349
- // See issue https://github.com/qooxdoo/qooxdoo/issues/9298
350
-
351
- var vRequestHeaders = this.getRequestHeaders();
352
-
353
- for (var vId in vRequestHeaders) {
354
- vRequest.setRequestHeader(vId, vRequestHeaders[vId]);
355
- }
356
-
357
- // --------------------------------------
358
- // Sending data
359
- // --------------------------------------
360
- try {
361
- if (qx.core.Environment.get("qx.debug"))
362
- {
363
- if (qx.core.Environment.get("qx.debug.io.remote.data"))
364
- {
365
- this.debug("Request: " + this.getData());
366
- }
367
- }
368
-
369
- // IE9 executes the call synchronous when the call is to file protocol
370
- // See [BUG #4762] for details
371
- if (
372
- vLocalRequest && vAsynchronous &&
373
- qx.core.Environment.get("engine.name") == "mshtml" &&
374
- (qx.core.Environment.get("engine.version") == 9 &&
375
- qx.core.Environment.get("browser.documentmode") == 9)
376
- ) {
377
- qx.event.Timer.once(function() {
378
- vRequest.send(this.getData());
379
- }, this, 0);
380
- } else {
381
- vRequest.send(this.getData());
382
- }
383
- }
384
- catch(ex)
385
- {
386
- if (vLocalRequest) {
387
- this.failedLocally();
388
- }
389
- else
390
- {
391
- this.error("Failed to send data to URL '" + vUrl + "': " + ex, "send");
392
- this.failed();
393
- }
394
-
395
- return;
396
- }
397
-
398
- // --------------------------------------
399
- // Readystate for sync requests
400
- // --------------------------------------
401
- if (!vAsynchronous) {
402
- this._onreadystatechange();
403
- }
404
- },
405
-
406
-
407
- /**
408
- * Force the transport into the failed state ("failed").
409
- *
410
- * This method should be used only if the requests URI was local
411
- * access. I.e. it started with "file://".
412
- *
413
- */
414
- failedLocally : function()
415
- {
416
- if (this.getState() === "failed") {
417
- return;
418
- }
419
-
420
- // should only occur on "file://" access
421
- this.warn("Could not load from file: " + this.getUrl());
422
-
423
- this.failed();
424
- },
425
-
426
-
427
-
428
-
429
- /*
430
- ---------------------------------------------------------------------------
431
- EVENT HANDLER
432
- ---------------------------------------------------------------------------
433
- */
434
-
435
- /**
436
- * Listener method for change of the "readystate".
437
- * Sets the internal state and informs the transport layer.
438
- *
439
- * @signature function(e)
440
- * @param e {Event} native event
441
- */
442
- _onreadystatechange : qx.event.GlobalError.observeMethod(function(e)
443
- {
444
- // Ignoring already stopped requests
445
- switch(this.getState())
446
- {
447
- case "completed":
448
- case "aborted":
449
- case "failed":
450
- case "timeout":
451
- if (qx.core.Environment.get("qx.debug"))
452
- {
453
- if (qx.core.Environment.get("qx.debug.io.remote")) {
454
- this.warn("Ignore Ready State Change");
455
- }
456
- }
457
-
458
- return;
459
- }
460
-
461
- // Checking status code
462
- var vReadyState = this.getReadyState();
463
-
464
- if (vReadyState == 4)
465
- {
466
- // The status code is only meaningful when we reach ready state 4.
467
- // (Important for Opera since it goes through other states before
468
- // reaching 4, and the status code is not valid before 4 is reached.)
469
- if (!qx.io.remote.Exchange.wasSuccessful(this.getStatusCode(), vReadyState, this.__localRequest)) {
470
- // Fix for bug #2272
471
- // The IE doesn't set the state to 'sending' even though the send method
472
- // is called. This only occurs if the server (which is called) goes
473
- // down or a network failure occurs.
474
- if (this.getState() === "configured") {
475
- this.setState("sending");
476
- }
477
-
478
- this.failed();
479
- return;
480
- }
481
- }
482
-
483
- // Sometimes the xhr call skips the send state
484
- if (vReadyState == 3 && this.__lastReadyState == 1) {
485
- this.setState(qx.io.remote.Exchange._nativeMap[++this.__lastReadyState]);
486
- }
487
-
488
- // Updating internal state
489
- while (this.__lastReadyState < vReadyState) {
490
- this.setState(qx.io.remote.Exchange._nativeMap[++this.__lastReadyState]);
491
- }
492
- }),
493
-
494
-
495
-
496
-
497
- /*
498
- ---------------------------------------------------------------------------
499
- READY STATE
500
- ---------------------------------------------------------------------------
501
- */
502
-
503
- /**
504
- * Get the ready state of this transports request.
505
- *
506
- * For qx.io.remote.transport.XmlHttp, ready state is a number between 1 to 4.
507
- *
508
- * @return {Integer} ready state number
509
- */
510
- getReadyState : function()
511
- {
512
- var vReadyState = null;
513
-
514
- try {
515
- vReadyState = this.getRequest().readyState;
516
- } catch(ex) {}
517
-
518
- return vReadyState;
519
- },
520
-
521
-
522
-
523
-
524
- /*
525
- ---------------------------------------------------------------------------
526
- REQUEST HEADER SUPPORT
527
- ---------------------------------------------------------------------------
528
- */
529
-
530
- /**
531
- * Set a request header to this transports request.
532
- *
533
- * @param vLabel {String} Request header name
534
- * @param vValue {var} Request header value
535
- */
536
- setRequestHeader : function(vLabel, vValue) {
537
- this.getRequestHeaders()[vLabel] = vValue;
538
- },
539
-
540
-
541
-
542
-
543
- /*
544
- ---------------------------------------------------------------------------
545
- RESPONSE HEADER SUPPORT
546
- ---------------------------------------------------------------------------
547
- */
548
-
549
- /**
550
- * Returns a specific header provided by the server upon sending a request,
551
- * with header name determined by the argument headerName.
552
- *
553
- * Only available at readyState 3 and 4 universally and in readyState 2
554
- * in Gecko.
555
- *
556
- * Please note: Some servers/proxies (such as Selenium RC) will capitalize
557
- * response header names. This is in accordance with RFC 2616[1], which
558
- * states that HTTP 1.1 header names are case-insensitive, so your
559
- * application should be case-agnostic when dealing with response headers.
560
- *
561
- * [1]<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2">RFC 2616: HTTP Message Headers</a>
562
- *
563
- * @param vLabel {String} Response header name
564
- * @return {String|null} Response header value
565
- */
566
- getResponseHeader : function(vLabel)
567
- {
568
- var vResponseHeader = null;
569
-
570
- try {
571
- vResponseHeader = this.getRequest().getResponseHeader(vLabel) || null;
572
- } catch(ex) {}
573
-
574
- return vResponseHeader;
575
- },
576
-
577
-
578
- /**
579
- * Returns all response headers of the request.
580
- *
581
- * @return {var} response headers
582
- */
583
- getStringResponseHeaders : function()
584
- {
585
- var vSourceHeader = null;
586
-
587
- try
588
- {
589
- var vLoadHeader = this.getRequest().getAllResponseHeaders();
590
-
591
- if (vLoadHeader) {
592
- vSourceHeader = vLoadHeader;
593
- }
594
- }
595
- catch(ex) {}
596
-
597
- return vSourceHeader;
598
- },
599
-
600
-
601
- /**
602
- * Provides a hash of all response headers.
603
- *
604
- * @return {var} hash of all response headers
605
- */
606
- getResponseHeaders : function()
607
- {
608
- var vSourceHeader = this.getStringResponseHeaders();
609
- var vHeader = {};
610
-
611
- if (vSourceHeader)
612
- {
613
- var vValues = vSourceHeader.split(/[\r\n]+/g);
614
-
615
- for (var i=0, l=vValues.length; i<l; i++)
616
- {
617
- var vPair = vValues[i].match(/^([^:]+)\s*:\s*(.+)$/i);
618
-
619
- if (vPair) {
620
- vHeader[vPair[1]] = vPair[2];
621
- }
622
- }
623
- }
624
-
625
- return vHeader;
626
- },
627
-
628
-
629
-
630
-
631
- /*
632
- ---------------------------------------------------------------------------
633
- STATUS SUPPORT
634
- ---------------------------------------------------------------------------
635
- */
636
-
637
- /**
638
- * Returns the current status code of the request if available or -1 if not.
639
- *
640
- * @return {Integer} current status code
641
- */
642
- getStatusCode : function()
643
- {
644
- var vStatusCode = -1;
645
-
646
- try {
647
- vStatusCode = this.getRequest().status;
648
-
649
- // [BUG #4476]
650
- // IE sometimes tells 1223 when it should be 204
651
- if (vStatusCode === 1223) {
652
- vStatusCode = 204;
653
- }
654
-
655
- } catch(ex) {}
656
-
657
- return vStatusCode;
658
- },
659
-
660
-
661
- /**
662
- * Provides the status text for the current request if available and null
663
- * otherwise.
664
- *
665
- * @return {String} current status code text
666
- */
667
- getStatusText : function()
668
- {
669
- var vStatusText = "";
670
-
671
- try {
672
- vStatusText = this.getRequest().statusText;
673
- } catch(ex) {}
674
-
675
- return vStatusText;
676
- },
677
-
678
-
679
-
680
-
681
- /*
682
- ---------------------------------------------------------------------------
683
- RESPONSE DATA SUPPORT
684
- ---------------------------------------------------------------------------
685
- */
686
-
687
- /**
688
- * Provides the response text from the request when available and null
689
- * otherwise. By passing true as the "partial" parameter of this method,
690
- * incomplete data will be made available to the caller.
691
- *
692
- * @return {String} Content of the response as string
693
- */
694
- getResponseText : function()
695
- {
696
- var vResponseText = null;
697
-
698
- try
699
- {
700
- vResponseText = this.getRequest().responseText;
701
- }
702
- catch(ex)
703
- {
704
- vResponseText = null;
705
- }
706
-
707
- return vResponseText;
708
- },
709
-
710
-
711
- /**
712
- * Provides the XML provided by the response if any and null otherwise. By
713
- * passing true as the "partial" parameter of this method, incomplete data will
714
- * be made available to the caller.
715
- *
716
- * @return {String} Content of the response as XML
717
- * @throws {Error} If an error within the response occurs.
718
- */
719
- getResponseXml : function()
720
- {
721
- var vResponseXML = null;
722
-
723
- var vStatus = this.getStatusCode();
724
- var vReadyState = this.getReadyState();
725
-
726
- if (qx.io.remote.Exchange.wasSuccessful(vStatus, vReadyState, this.__localRequest))
727
- {
728
- try {
729
- vResponseXML = this.getRequest().responseXML;
730
- } catch(ex) {}
731
- }
732
-
733
- // Typical behaviour on file:// on mshtml
734
- // Could we check this with something like: /^file\:/.test(path); ?
735
- // No browser check here, because it doesn't seem to break other browsers
736
- // * test for this.req.responseXML's objecthood added by *
737
- // * FRM, 20050816 *
738
- if (typeof vResponseXML == "object" && vResponseXML != null)
739
- {
740
- if (!vResponseXML.documentElement)
741
- {
742
- // Clear xml file declaration, this breaks non unicode files (like ones with Umlauts)
743
- var s = String(this.getRequest().responseText).replace(/<\?xml[^\?]*\?>/, "");
744
- vResponseXML.loadXML(s);
745
- }
746
-
747
- // Re-check if fixed...
748
- if (!vResponseXML.documentElement) {
749
- throw new Error("Missing Document Element!");
750
- }
751
-
752
- if (vResponseXML.documentElement.tagName == "parseerror") {
753
- throw new Error("XML-File is not well-formed!");
754
- }
755
- }
756
- else
757
- {
758
- throw new Error("Response was not a valid xml document [" + this.getRequest().responseText + "]");
759
- }
760
-
761
- return vResponseXML;
762
- },
763
-
764
-
765
- /**
766
- * Returns the length of the content as fetched thus far
767
- *
768
- * @return {Integer} Length of the response text.
769
- */
770
- getFetchedLength : function()
771
- {
772
- var vText = this.getResponseText();
773
- return typeof vText == "string" ? vText.length : 0;
774
- },
775
-
776
-
777
- /**
778
- * Returns the content of the response
779
- *
780
- * @return {null | String} Response content if available
781
- */
782
- getResponseContent : function()
783
- {
784
- var state = this.getState();
785
- if (state !== "completed" && state != "failed")
786
- {
787
- if (qx.core.Environment.get("qx.debug"))
788
- {
789
- if (qx.core.Environment.get("qx.debug.io.remote")) {
790
- this.warn("Transfer not complete or failed, ignoring content!");
791
- }
792
- }
793
-
794
- return null;
795
- }
796
-
797
- if (qx.core.Environment.get("qx.debug"))
798
- {
799
- if (qx.core.Environment.get("qx.debug.io.remote")) {
800
- this.debug("Returning content for responseType: " + this.getResponseType());
801
- }
802
- }
803
-
804
- var vText = this.getResponseText();
805
-
806
- if (state == "failed")
807
- {
808
- if (qx.core.Environment.get("qx.debug"))
809
- {
810
- if (qx.core.Environment.get("qx.debug.io.remote.data"))
811
- {
812
- this.debug("Failed: " + vText);
813
- }
814
- }
815
-
816
- return vText;
817
- }
818
-
819
- switch(this.getResponseType())
820
- {
821
- case "text/plain":
822
- case "text/html":
823
- if (qx.core.Environment.get("qx.debug"))
824
- {
825
- if (qx.core.Environment.get("qx.debug.io.remote.data"))
826
- {
827
- this.debug("Response: " + vText);
828
- }
829
- }
830
-
831
- return vText;
832
-
833
- case "application/json":
834
- if (qx.core.Environment.get("qx.debug"))
835
- {
836
- if (qx.core.Environment.get("qx.debug.io.remote.data"))
837
- {
838
- this.debug("Response: " + vText);
839
- }
840
- }
841
-
842
- try {
843
- if (vText && vText.length > 0)
844
- {
845
- var ret;
846
- if (this.getParseJson()){
847
- ret = qx.lang.Json.parse(vText);
848
- ret = (ret === 0 ? 0 : (ret || null));
849
- } else {
850
- ret = vText;
851
- }
852
- return ret;
853
- }
854
- else
855
- {
856
- return null;
857
- }
858
- }
859
- catch(ex)
860
- {
861
- this.error("Could not execute json: [" + vText + "]", ex);
862
- return "<pre>Could not execute json: \n" + vText + "\n</pre>";
863
- }
864
-
865
- case "text/javascript":
866
- if (qx.core.Environment.get("qx.debug"))
867
- {
868
- if (qx.core.Environment.get("qx.debug.io.remote.data"))
869
- {
870
- this.debug("Response: " + vText);
871
- }
872
- }
873
-
874
- try {
875
- if(vText && vText.length > 0)
876
- {
877
- var ret = window.eval(vText);
878
- return (ret === 0 ? 0 : (ret || null));
879
- }
880
- else
881
- {
882
- return null;
883
- }
884
- } catch(ex) {
885
- this.error("Could not execute javascript: [" + vText + "]", ex);
886
- return null;
887
- }
888
-
889
- case "application/xml":
890
- vText = this.getResponseXml();
891
-
892
- if (qx.core.Environment.get("qx.debug"))
893
- {
894
- if (qx.core.Environment.get("qx.debug.io.remote.data"))
895
- {
896
- this.debug("Response: " + vText);
897
- }
898
- }
899
-
900
- return (vText === 0 ? 0 : (vText || null));
901
-
902
- default:
903
- this.warn("No valid responseType specified (" + this.getResponseType() + ")!");
904
- return null;
905
- }
906
- },
907
-
908
-
909
-
910
-
911
- /*
912
- ---------------------------------------------------------------------------
913
- APPLY ROUTINES
914
- ---------------------------------------------------------------------------
915
- */
916
-
917
- /**
918
- * Apply method for the "state" property.
919
- * Fires an event for each state value to inform the listeners.
920
- *
921
- * @param value {var} Current value
922
- * @param old {var} Previous value
923
- */
924
- _applyState : function(value, old)
925
- {
926
- if (qx.core.Environment.get("qx.debug"))
927
- {
928
- if (qx.core.Environment.get("qx.debug.io.remote")) {
929
- this.debug("State: " + value);
930
- }
931
- }
932
-
933
- switch(value)
934
- {
935
- case "created":
936
- this.fireEvent("created");
937
- break;
938
-
939
- case "configured":
940
- this.fireEvent("configured");
941
- break;
942
-
943
- case "sending":
944
- this.fireEvent("sending");
945
- break;
946
-
947
- case "receiving":
948
- this.fireEvent("receiving");
949
- break;
950
-
951
- case "completed":
952
- this.fireEvent("completed");
953
- break;
954
-
955
- case "failed":
956
- this.fireEvent("failed");
957
- break;
958
-
959
- case "aborted":
960
- this.getRequest().abort();
961
- this.fireEvent("aborted");
962
- break;
963
-
964
- case "timeout":
965
- this.getRequest().abort();
966
- this.fireEvent("timeout");
967
- break;
968
- }
969
- }
970
- },
971
-
972
-
973
-
974
- /*
975
- *****************************************************************************
976
- DEFER
977
- *****************************************************************************
978
- */
979
-
980
- defer : function()
981
- {
982
- // basic registration to qx.io.remote.Exchange
983
- // the real availability check (activeX stuff and so on) follows at the first real request
984
- qx.io.remote.Exchange.registerType(qx.io.remote.transport.XmlHttp, "qx.io.remote.transport.XmlHttp");
985
- },
986
-
987
-
988
-
989
-
990
- /*
991
- *****************************************************************************
992
- DESTRUCTOR
993
- *****************************************************************************
994
- */
995
-
996
- destruct : function()
997
- {
998
- var vRequest = this.getRequest();
999
-
1000
- if (vRequest)
1001
- {
1002
- // Clean up state change handler
1003
- // Note that for IE the proper way to do this is to set it to a
1004
- // dummy function, not null (Google on "onreadystatechange dummy IE unhook")
1005
- // http://groups.google.com/group/Google-Web-Toolkit-Contributors/browse_thread/thread/7e7ee67c191a6324
1006
- vRequest.onreadystatechange = (function() {});
1007
- // Aborting
1008
- switch(vRequest.readyState)
1009
- {
1010
- case 1:
1011
- case 2:
1012
- case 3:
1013
- vRequest.abort();
1014
- }
1015
- }
1016
-
1017
- this.__request = null;
1018
- }
1019
- });