~ubuntu-branches/ubuntu/lucid/loggerhead/lucid-security

« back to all changes in this revision

Viewing changes to loggerhead/static/javascript/yui/build/io/io-base.js

  • Committer: Bazaar Package Importer
  • Author(s): James Westby, Roland Mas, Jelmer Vernooij, James Westby
  • Date: 2009-08-26 13:18:03 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090826131803-0ce1fhaetci8b0c5
Tags: 1.17-0ubuntu1
[ Roland Mas ]
* Use the YUI library provided by libjs-yui. (Closes: #511286)

[ Jelmer Vernooij ]
* Use my debian.org address in Uploaders field.
* Add ${misc:Depends} to please lintian.
* Suggest recent version of paste, which doesn't expose internal port
  numbers in links. (Closes: #507000)
* Bump standards version to 3.8.1.

[ James Westby ]
* New upstream release.
* Drop get-orig-source rule in favour of debian/watch.
* Add python-pkg-resources and python-paste to Build-Depends,
  python-pkg-resources to Depends and python-simplejson to
  Recommends due to dependency changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
 
3
Code licensed under the BSD License:
 
4
http://developer.yahoo.net/yui/license.txt
 
5
version: 3.0.0pr2
 
6
*/
 
7
YUI.add('io-base', function(Y) {
 
8
 
 
9
   /**
 
10
        * HTTP communications module.
 
11
        * @module io
 
12
        */
 
13
 
 
14
   /**
 
15
    * The io class is a utility that brokers HTTP requests through a simplified
 
16
    * interface.  Specifically, it allows JavaScript to make HTTP requests to
 
17
    * a resource without a page reload.  The underlying transport for making
 
18
    * same-domain requests is the XMLHttpRequest object.  YUI.io can also use
 
19
    * Flash, if specified as a transport, for cross-domain requests.
 
20
    *
 
21
        * @class io
 
22
        */
 
23
 
 
24
   /**
 
25
        * @event io:start
 
26
        * @description This event is fired by YUI.io when a transaction is initiated..
 
27
        * @type Event Custom
 
28
        */
 
29
        var E_START = 'io:start',
 
30
 
 
31
   /**
 
32
        * @event io:complete
 
33
        * @description This event is fired by YUI.io when a transaction is complete and
 
34
        * all response data are available.
 
35
        * @type Event Custom
 
36
        */
 
37
        E_COMPLETE = 'io:complete',
 
38
 
 
39
   /**
 
40
        * @event io:success
 
41
        * @description This event is fired by YUI.io when a transaction is complete and
 
42
        * the HTTP status resolves to HTTP2xx.
 
43
        * @type Event Custom
 
44
        */
 
45
        E_SUCCESS = 'io:success',
 
46
 
 
47
   /**
 
48
        * @event io:failure
 
49
        * @description This event is fired by YUI.io when a transaction is complete and
 
50
        * the HTTP status resolves to HTTP4xx, 5xx and above.
 
51
        * @type Event Custom
 
52
        */
 
53
        E_FAILURE = 'io:failure',
 
54
 
 
55
   /**
 
56
        * @event io:abort
 
57
        * @description This event is fired by YUI.io when a transaction is aborted
 
58
        * explicitly or by a defined config.timeout.
 
59
        * @type Event Custom
 
60
        */
 
61
        E_ABORT = 'io:abort',
 
62
 
 
63
        //--------------------------------------
 
64
        //  Properties
 
65
        //--------------------------------------
 
66
   /**
 
67
        * @description A transaction counter that increments for each transaction.
 
68
        *
 
69
        * @property transactionId
 
70
        * @private
 
71
        * @static
 
72
        * @type int
 
73
        */
 
74
        transactionId = 0,
 
75
 
 
76
   /**
 
77
        * @description Object of default HTTP headers to be initialized and sent
 
78
        * for all transactions.
 
79
        *
 
80
        * @property _headers
 
81
        * @private
 
82
        * @static
 
83
        * @type object
 
84
        */
 
85
        _headers = {
 
86
                'X-Requested-With' : 'XMLHttpRequest'
 
87
        },
 
88
 
 
89
   /**
 
90
        * @description Object that stores timeout values for any transaction with
 
91
        * a defined "timeout" configuration property.
 
92
        *
 
93
        * @property _timeOut
 
94
        * @private
 
95
        * @static
 
96
        * @type object
 
97
        */
 
98
        _timeout = {};
 
99
 
 
100
        //--------------------------------------
 
101
        //  Methods
 
102
        //--------------------------------------
 
103
 
 
104
        // Window reference
 
105
        w = Y.config.win;
 
106
 
 
107
   /**
 
108
        * @description Method for requesting a transaction. _io() is implemented as
 
109
        * yui.io().  Each transaction may include a configuration object.  Its
 
110
        * properties are:
 
111
        *
 
112
        * method: HTTP method verb (e.g., GET or POST). If this property is not
 
113
        *         not defined, the default value will be GET.
 
114
        *
 
115
        * data: This is the name-value string that will be sent as the transaction
 
116
    *           data.  If the request is HTTP GET, the data become part of
 
117
    *           querystring. If HTTP POST, the data are sent in the message body.
 
118
        *
 
119
        * xdr: Defines the transport to be used for cross-domain requests.  By
 
120
        *      setting this property, the transaction will use the specified
 
121
        *      transport instead of XMLHttpRequest.  Currently, the only alternate
 
122
        *      transport supported is Flash (e.g., { xdr: 'flash' }).
 
123
        *
 
124
        * form: This is a defined object used to process HTML form as data.  The
 
125
        *       properties are:
 
126
        *       {
 
127
        *             id: object, //HTML form object or id of HTML form
 
128
        *         useDisabled: boolean, //Allow disabled HTML form field values
 
129
        *                      to be sent as part of the data.
 
130
    *       }
 
131
    *
 
132
    * on: This is a defined object used to create and handle specific
 
133
    *     events during a transaction lifecycle.  These events will fire in
 
134
    *     addition to the global io events. The events are:
 
135
    *     start - This event is fired when a request is sent to a resource.
 
136
    *     complete - This event fires when the transaction is complete.
 
137
    *     success - This event fires when the response status resolves to
 
138
    *               HTTP 2xx.
 
139
    *     failure - This event fires when the response status resolves to
 
140
    *               HTTP 4xx, 5xx, and beyond.
 
141
    *     abort - This even is fired when a transaction abort is fire by
 
142
    *             timeout, or when it is manually aborted.
 
143
    *
 
144
    *     The properties are:
 
145
    *     {
 
146
        *       start: function(id, args){},
 
147
        *       complete: function(id, responseobject, args){},
 
148
        *       success: function(id, responseobject, args){},
 
149
        *       failure: function(id, responseobject, args){},
 
150
        *       abort: function(id, args){}
 
151
        *     }
 
152
        *         Each property can reference a function or be written as an
 
153
        *     inline function.
 
154
        *
 
155
        * context: Object reference for an event handler when it is implemented
 
156
        *          as a method of a base object. Defining "context" will preserve
 
157
        *          the proper reference of "this" used in the event handler.
 
158
        * headers: This is a defined object of client headers, as many as.
 
159
        *         desired for the transaction.  These headers are sentThe object
 
160
        *         pattern is:
 
161
        *                 {
 
162
        *                   header: value
 
163
        *         }
 
164
        *
 
165
        * timeout: This value, defined as milliseconds, is a time threshold for the
 
166
        *          transaction. When this threshold is reached, and the transaction's
 
167
        *          Complete event has not yet fired, the transaction will be aborted.
 
168
        * arguments: Object, array, string, or number passed to all registered
 
169
        *            event handlers.  This value is available as the second
 
170
        *            argument in the "start" and "abort" event handlers; and, it is
 
171
        *            the third argument in the "complete", "success", and "failure"
 
172
        *            event handlers.
 
173
        *
 
174
        * @method _io
 
175
        * @private
 
176
        * @static
 
177
    * @param {string} uri - qualified path to transaction resource.
 
178
    * @param {object} c - configuration object for the transaction.
 
179
    * @return object
 
180
        */
 
181
        function _io(uri, c) {
 
182
                var c = c || {},
 
183
                o = _create((arguments.length === 3) ? arguments[2] : null, c),
 
184
                m = (c.method) ? c.method.toUpperCase() : 'GET',
 
185
                d = (c.data) ? c.data : null,
 
186
                f;
 
187
 
 
188
                /* Determine configuration properties */
 
189
                // If config.form is defined, perform data operations.
 
190
                if (c.form) {
 
191
 
 
192
                        if (c.form.upload) {
 
193
                                u = Y.io._upload(o, uri, c);
 
194
                                return u;
 
195
                        }
 
196
 
 
197
                        // Serialize the HTML form into a string of name-value pairs.
 
198
                        f = Y.io._serialize(c.form);
 
199
                        // If config.data is defined, concatenate the data to the form string.
 
200
                        if (d) {
 
201
                                f += "&" + d;
 
202
                        }
 
203
 
 
204
                        if (m === 'POST') {
 
205
                                d = f;
 
206
                                _setHeader('Content-Type', 'application/x-www-form-urlencoded');
 
207
                        }
 
208
                        else if (m === 'GET') {
 
209
                                uri = _concat(uri, f);
 
210
                        }
 
211
                }
 
212
                else if (d && m === 'GET') {
 
213
                        uri = _concat(uri, c.data);
 
214
                }
 
215
                else if (d && m === 'POST') {
 
216
                        _setHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
 
217
                }
 
218
 
 
219
                if (c.xdr) {
 
220
                        Y.io._xdr(uri, o, c);
 
221
                        return o;
 
222
                }
 
223
 
 
224
                // If config.timeout is defined, and the request is standard XHR,
 
225
                // initialize timeout polling.
 
226
                if (c.timeout) {
 
227
                        _startTimeout(o, c);
 
228
                }
 
229
                /* End Configuration Properties */
 
230
 
 
231
                o.c.onreadystatechange = function() { _readyState(o, c); };
 
232
                try {
 
233
                        _open(o.c, m, uri);
 
234
                }
 
235
                catch (e) {
 
236
                }
 
237
                _setHeaders(o.c, (c.headers || {}));
 
238
 
 
239
                o.abort = function () {
 
240
                        _ioAbort(o, c);
 
241
                }
 
242
 
 
243
                o.isInProgress = function() {
 
244
                        return o.c.readyState !== 4 && o.c.readyState !== 0;
 
245
                }
 
246
                // Do not pass null, in the absence of data, as this
 
247
                // will result in a POST request with no Content-Length
 
248
                // defined.
 
249
                _async(o, (d || ''), c);
 
250
 
 
251
                return o;
 
252
        };
 
253
 
 
254
   /**
 
255
        * @description Method for creating and subscribing transaction events.
 
256
        *
 
257
        * @method _tPubSub
 
258
        * @private
 
259
        * @static
 
260
        * @param {string} e - event to be published
 
261
        * @param {object} c - configuration object for the transaction.
 
262
        *
 
263
    * @return void
 
264
        */
 
265
        function _tPubSub(e, c){
 
266
                        var event = new Y.Event.Target().publish('transaction:' + e);
 
267
                        event.subscribe(c.on[e], (c.context || this), c.arguments);
 
268
 
 
269
                        return event;
 
270
        };
 
271
 
 
272
   /**
 
273
        * @description Fires event "io:start" and creates, fires a
 
274
        * transaction-specific start event, if config.on.start is
 
275
        * defined.
 
276
        *
 
277
        * @method _ioStart
 
278
        * @private
 
279
        * @static
 
280
        * @param {number} id - transaction id
 
281
        * @param {object} c - configuration object for the transaction.
 
282
        *
 
283
    * @return void
 
284
        */
 
285
        function _ioStart(id, c) {
 
286
                // Set default value of argument c, property "on" to Object if
 
287
                // the property is null or undefined.
 
288
                c.on = c.on || {};
 
289
                var m = Y.io._fn || {},
 
290
                fn = (m && m[id]) ? m[id] : null,
 
291
                event;
 
292
 
 
293
                if (fn) {
 
294
                        c.on.start = fn.start;
 
295
                        delete fn;
 
296
                }
 
297
 
 
298
                Y.fire(E_START, id);
 
299
                if (c.on.start) {
 
300
                        event = _tPubSub('start', c);
 
301
                        event.fire(id);
 
302
                }
 
303
        };
 
304
 
 
305
   /**
 
306
        * @description Fires event "io:complete" and creates, fires a
 
307
        * transaction-specific "complete" event, if config.on.complete is
 
308
        * defined.
 
309
        *
 
310
        * @method _ioComplete
 
311
        * @private
 
312
        * @static
 
313
        * @param {object} o - transaction object.
 
314
        * @param {object} c - configuration object for the transaction.
 
315
        *
 
316
    * @return void
 
317
        */
 
318
        function _ioComplete(o, c) {
 
319
                // Set default value of argument c, property "on" to Object if
 
320
                // the property is null or undefined.
 
321
                c.on = c.on || {};
 
322
                var event;
 
323
 
 
324
                Y.fire(E_COMPLETE, o.id, o.c);
 
325
                if (c.on.complete) {
 
326
                        event = _tPubSub('complete', c);
 
327
                        event.fire(o.id, o.c);
 
328
                }
 
329
        }
 
330
 
 
331
   /**
 
332
        * @description Fires event "io:success" and creates, fires a
 
333
        * transaction-specific "success" event, if config.on.success is
 
334
        * defined.
 
335
        *
 
336
        * @method _ioSuccess
 
337
        * @private
 
338
        * @static
 
339
        * @param {object} o - transaction object.
 
340
        * @param {object} c - configuration object for the transaction.
 
341
        *
 
342
    * @return void
 
343
        */
 
344
        function _ioSuccess(o, c) {
 
345
                // Set default value of argument c, property "on" to Object if
 
346
                // the property is null or undefined.
 
347
                c.on = c.on || {};
 
348
                var m = Y.io._fn || {},
 
349
                fn = (m && m[o.id]) ? m[o.id] : null,
 
350
                event;
 
351
 
 
352
                if (fn) {
 
353
                        c.on.success = fn.success;
 
354
                        delete fn;
 
355
                        //Decode the response from IO.swf
 
356
                        o.c.responseText = decodeURI(o.c.responseText);
 
357
                }
 
358
 
 
359
                Y.fire(E_SUCCESS, o.id, o.c);
 
360
                if (c.on.success) {
 
361
                        event = _tPubSub('success', c);
 
362
                        event.fire(o.id, o.c);
 
363
                }
 
364
 
 
365
                _destroy(o, (c.xdr) ? true : false );
 
366
        }
 
367
 
 
368
   /**
 
369
        * @description Fires event "io:failure" and creates, fires a
 
370
        * transaction-specific "failure" event, if config.on.failure is
 
371
        * defined.
 
372
        *
 
373
        * @method _ioFailure
 
374
        * @private
 
375
        * @static
 
376
        * @param {object} o - transaction object.
 
377
        * @param {object} c - configuration object for the transaction.
 
378
        *
 
379
    * @return void
 
380
        */
 
381
        function _ioFailure(o, c) {
 
382
                // Set default value of argument c, property "on" to Object if
 
383
                // the property is null or undefined.
 
384
                c.on = c.on || {};
 
385
                var m = Y.io._fn || {},
 
386
                fn = (m && m[o.id]) ? m[o.id] : null,
 
387
                event;
 
388
 
 
389
                if (fn) {
 
390
                        c.on.failure = fn.failure;
 
391
                        delete fn;
 
392
                        //Decode the response from IO.swf
 
393
                        o.c.responseText = decodeURI(o.c.responseText);
 
394
                }
 
395
 
 
396
                Y.fire(E_FAILURE, o.id, o.c);
 
397
                if (c.on.failure) {
 
398
                        event = _tPubSub('failure', c);
 
399
                        event.fire(o.id, o.c);
 
400
                }
 
401
 
 
402
                _destroy(o, (c.xdr) ? true : false );
 
403
        }
 
404
 
 
405
   /**
 
406
        * @description Fires event "io:abort" and creates, fires a
 
407
        * transaction-specific "abort" event, if config.on.abort is
 
408
        * defined.
 
409
        *
 
410
        * @method _ioAbort
 
411
        * @private
 
412
        * @static
 
413
    * @param {object} o - Transaction object generated by _create().
 
414
    * @param {object} c - Configuration object passed to YUI.io().
 
415
        *
 
416
    * @return void
 
417
        */
 
418
        function _ioAbort(o, c) {
 
419
                // Set default value of argument c, property "on" to Object if
 
420
                // the property is null or undefined.
 
421
                c.on = c.on || {};
 
422
                var m = Y.io._fn || {},
 
423
                fn = (m && m[o.id]) ? m[o.id] : null,
 
424
                event;
 
425
 
 
426
                if(o && o.c  && !c.xdr) {
 
427
                        // Terminate the transaction
 
428
                        o.c.abort();
 
429
                        if (c) {
 
430
                                // Clear the timeout poll for this specific transaction.
 
431
                                if (c.timeout) {
 
432
                                        _clearTimeout(o.id);
 
433
                                }
 
434
                        }
 
435
                }
 
436
 
 
437
                if (fn) {
 
438
                        c.on.abort = fn.abort;
 
439
                        delete fn;
 
440
                }
 
441
 
 
442
                Y.fire(E_ABORT, o.id);
 
443
                if (c.on.abort) {
 
444
                        event = _tPubSub('abort', c);
 
445
                        event.fire(id);
 
446
                }
 
447
 
 
448
                _destroy(o, (c.xdr) ? true : false );
 
449
        }
 
450
 
 
451
   /**
 
452
        * @description Method that increments _transactionId for each transaction.
 
453
        *
 
454
        * @method _id
 
455
        * @private
 
456
        * @static
 
457
    * @return int
 
458
        */
 
459
        function _id() {
 
460
                var id = transactionId;
 
461
                transactionId++;
 
462
 
 
463
                return id;
 
464
        };
 
465
 
 
466
   /**
 
467
        * @description Method that creates a unique transaction object for each
 
468
        * request..
 
469
        *
 
470
        * @method _create
 
471
        * @private
 
472
        * @static
 
473
    * @param {number} s - URI or root data.
 
474
    * @param {number} c - configuration object
 
475
    * @return object
 
476
        */
 
477
        function _create(i, c) {
 
478
                var o = {};
 
479
                o.id = Y.Lang.isNumber(i) ? i : _id();
 
480
 
 
481
                if (c.xdr) {
 
482
                        o.c = Y.io._transportMap[c.xdr.use];
 
483
                }
 
484
                else if (c.form && c.form.upload) {
 
485
                        o.c = {};
 
486
                }
 
487
                else {
 
488
                        o.c = _xhr();
 
489
                }
 
490
 
 
491
                return o;
 
492
        };
 
493
 
 
494
   /**
 
495
        * @description Method that creates the XMLHttpRequest transport
 
496
        *
 
497
        * @method _xhr
 
498
        * @private
 
499
        * @static
 
500
    * @return object
 
501
        */
 
502
        function _xhr() {
 
503
                return (w.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
 
504
        };
 
505
 
 
506
   /**
 
507
        * @description Method that concatenates string data for HTTP GET transactions.
 
508
        *
 
509
        * @method _concat
 
510
        * @private
 
511
        * @static
 
512
    * @param {string} s - URI or root data.
 
513
    * @param {string} d - data to be concatenated onto URI.
 
514
    * @return int
 
515
        */
 
516
        function _concat(s, d) {
 
517
                s += ((s.indexOf('?') == -1) ? '?' : '&') + d;
 
518
                return s;
 
519
        };
 
520
 
 
521
   /**
 
522
        * @description Method that stores default client headers for all transactions.
 
523
        * If a label is passed with no value argument, the header will be deleted.
 
524
        *
 
525
        * @method _setHeader
 
526
        * @private
 
527
        * @static
 
528
    * @param {string} l - HTTP header
 
529
    * @param {string} v - HTTP header value
 
530
    * @return int
 
531
        */
 
532
        function _setHeader(l, v) {
 
533
                if (v) {
 
534
                        _headers[l] = v;
 
535
                }
 
536
                else {
 
537
                        delete _headers[l];
 
538
                }
 
539
        };
 
540
 
 
541
   /**
 
542
        * @description Method that sets all HTTP headers to be sent in a transaction.
 
543
        *
 
544
        * @method _setHeaders
 
545
        * @private
 
546
        * @static
 
547
    * @param {object} o - XHR instance for the specific transaction.
 
548
    * @param {object} h - HTTP headers for the specific transaction, as defined
 
549
    *                     in the configuration object passed to YUI.io().
 
550
    * @return void
 
551
        */
 
552
        function _setHeaders(o, h) {
 
553
 
 
554
                var p;
 
555
 
 
556
                for (p in _headers) {
 
557
                        if (_headers.hasOwnProperty(p)) {
 
558
                                if (h[p]) {
 
559
                                        // Configuration headers will supersede IO preset headers,
 
560
                                        // if headers match.
 
561
                                        break;
 
562
                                }
 
563
                                else {
 
564
                                        h[p] = _headers[p];
 
565
                                }
 
566
                        }
 
567
                }
 
568
 
 
569
                for (p in h) {
 
570
                        if (h.hasOwnProperty(p)) {
 
571
                                o.setRequestHeader(p, h[p]);
 
572
                        }
 
573
                }
 
574
        };
 
575
 
 
576
        function _open(o, m, uri) {
 
577
                o.open(m, uri, true);
 
578
        };
 
579
 
 
580
   /**
 
581
        * @description Method that sends the transaction request.
 
582
        *
 
583
        * @method _async
 
584
        * @private
 
585
        * @static
 
586
    * @param {object} o - Transaction object generated by _create().
 
587
    * @param {string} d - Transaction data.
 
588
    * @param {object} c - Configuration object passed to YUI.io().
 
589
    * @return void
 
590
        */
 
591
        function _async(o, d, c) {
 
592
                o.c.send(d);
 
593
                _ioStart(o.id, c);
 
594
        };
 
595
 
 
596
   /**
 
597
        * @description Starts timeout count if the configuration object
 
598
        * has a defined timeout property.
 
599
        *
 
600
        * @method _startTimeout
 
601
        * @private
 
602
        * @static
 
603
    * @param {object} o - Transaction object generated by _create().
 
604
    * @param {object} c - Configuration object passed to YUI.io().
 
605
    * @return void
 
606
        */
 
607
        function _startTimeout(o, c) {
 
608
                _timeout[o.id] = w.setTimeout(function() { _ioAbort(o, c); }, c.timeout);
 
609
        };
 
610
 
 
611
   /**
 
612
        * @description Clears the timeout interval started by _startTimeout().
 
613
        *
 
614
        * @method _clearTimeout
 
615
        * @private
 
616
        * @static
 
617
    * @param {number} id - Transaction id.
 
618
    * @return void
 
619
        */
 
620
        function _clearTimeout(id) {
 
621
                w.clearTimeout(_timeout[id]);
 
622
                delete _timeout[id];
 
623
        };
 
624
 
 
625
   /**
 
626
        * @description Event handler bound to onreadystatechange.
 
627
        *
 
628
        * @method _readyState
 
629
        * @private
 
630
        * @static
 
631
    * @param {object} o - Transaction object generated by _create().
 
632
    * @param {object} c - Configuration object passed to YUI.io().
 
633
    * @return void
 
634
        */
 
635
        function _readyState(o, c) {
 
636
                if (o.c.readyState === 4) {
 
637
                        if (c.timeout) {
 
638
                                _clearTimeout(o.id);
 
639
                        }
 
640
                        _ioComplete(o, c);
 
641
                        _handleResponse(o, c);
 
642
                }
 
643
        };
 
644
 
 
645
   /**
 
646
        * @description Method that determines if a transaction response qualifies
 
647
        * as success or failure, based on the response HTTP status code, and
 
648
        * fires the appropriate success or failure events.
 
649
        *
 
650
        * @method _handleResponse
 
651
        * @private
 
652
        * @static
 
653
    * @param {object} o - Transaction object generated by _create().
 
654
    * @param {object} c - Configuration object passed to YUI.io().
 
655
    * @return void
 
656
        */
 
657
        function _handleResponse(o, c) {
 
658
                var status;
 
659
                try{
 
660
                        if (o.c.status && o.c.status !== 0) {
 
661
                                status = o.c.status;
 
662
                        }
 
663
                        else {
 
664
                                status = 0;
 
665
                        }
 
666
                }
 
667
                catch(e) {
 
668
                        status = 0;
 
669
                }
 
670
 
 
671
                /*
 
672
                 * IE reports HTTP 204 as HTTP 1223.
 
673
                 * However, the response data are still available.
 
674
                 *
 
675
                 * setTimeout() is used to prevent transactions from becoming
 
676
                 * synchronous, in IE, when the response data are read from cache
 
677
                 * (e.g., HTTP 304).
 
678
                 */
 
679
                if (status >= 200 && status < 300 || status === 1223) {
 
680
                        w.setTimeout( function() { _ioSuccess(o, c); }, 0);
 
681
                }
 
682
                else {
 
683
                        w.setTimeout( function() {_ioFailure(o, c); }, 0);
 
684
                }
 
685
        };
 
686
 
 
687
        function _destroy(o, isTransport) {
 
688
                // IE6 will throw a "Type Mismatch" error if the event handler is set to "null".
 
689
                if(w.XMLHttpRequest && !isTransport) {
 
690
                        if (o.c) {
 
691
                                o.c.onreadystatechange = null;
 
692
                        }
 
693
                }
 
694
 
 
695
                o.c = null;
 
696
                o = null;
 
697
        };
 
698
 
 
699
        _io.start = _ioStart;
 
700
        _io.complete = _ioComplete;
 
701
        _io.success = _ioSuccess;
 
702
        _io.failure = _ioFailure;
 
703
        _io.abort = _ioAbort;
 
704
        _io._id = _id;
 
705
        _io._timeout = _timeout;
 
706
 
 
707
        //--------------------------------------
 
708
        //  Begin public interface definition
 
709
        //--------------------------------------
 
710
   /**
 
711
        * @description Method that stores default client headers for all transactions.
 
712
        * If a label is passed with no value argument, the header will be deleted.
 
713
        * This is the interface for _setHeader().
 
714
        *
 
715
        * @method header
 
716
        * @public
 
717
        * @static
 
718
    * @param {string} l - HTTP header
 
719
    * @param {string} v - HTTP header value
 
720
    * @return int
 
721
        */
 
722
        _io.header = _setHeader;
 
723
 
 
724
   /**
 
725
        * @description Method for requesting a transaction. This
 
726
        * is the interface for _io().
 
727
        *
 
728
        * @method io
 
729
        * @public
 
730
        * @static
 
731
    * @param {string} uri - qualified path to transaction resource.
 
732
    * @param {object} c - configuration object for the transaction.
 
733
    * @return object
 
734
    */
 
735
        Y.io = _io;
 
736
 
 
737
 
 
738
 
 
739
}, '3.0.0pr2' );