Revision 1374
Added by Dietmar over 13 years ago
connection.js | ||
---|---|---|
26 | 26 |
YAHOO.util.Connect = |
27 | 27 |
{ |
28 | 28 |
/** |
29 |
* @description Array of MSFT ActiveX ids for XMLHttpRequest.
|
|
30 |
* @property _msxml_progid
|
|
31 |
* @private
|
|
32 |
* @static
|
|
33 |
* @type array
|
|
29 |
* @description Array of MSFT ActiveX ids for XMLHttpRequest. |
|
30 |
* @property _msxml_progid |
|
31 |
* @private |
|
32 |
* @static |
|
33 |
* @type array |
|
34 | 34 |
*/ |
35 | 35 |
_msxml_progid:[ |
36 | 36 |
'Microsoft.XMLHTTP', |
... | ... | |
39 | 39 |
], |
40 | 40 |
|
41 | 41 |
/** |
42 |
* @description Object literal of HTTP header(s)
|
|
43 |
* @property _http_header
|
|
44 |
* @private
|
|
45 |
* @static
|
|
46 |
* @type object
|
|
42 |
* @description Object literal of HTTP header(s) |
|
43 |
* @property _http_header |
|
44 |
* @private |
|
45 |
* @static |
|
46 |
* @type object |
|
47 | 47 |
*/ |
48 | 48 |
_http_headers:{}, |
49 | 49 |
|
50 | 50 |
/** |
51 |
* @description Determines if HTTP headers are set.
|
|
52 |
* @property _has_http_headers
|
|
53 |
* @private
|
|
54 |
* @static
|
|
55 |
* @type boolean
|
|
51 |
* @description Determines if HTTP headers are set. |
|
52 |
* @property _has_http_headers |
|
53 |
* @private |
|
54 |
* @static |
|
55 |
* @type boolean |
|
56 | 56 |
*/ |
57 | 57 |
_has_http_headers:false, |
58 | 58 |
|
59 | 59 |
/** |
60 |
* @description Determines if a default header of
|
|
60 |
* @description Determines if a default header of |
|
61 | 61 |
* Content-Type of 'application/x-www-form-urlencoded' |
62 | 62 |
* will be added to any client HTTP headers sent for POST |
63 | 63 |
* transactions. |
64 |
* @property _use_default_post_header
|
|
65 |
* @private
|
|
66 |
* @static
|
|
67 |
* @type boolean
|
|
64 |
* @property _use_default_post_header |
|
65 |
* @private |
|
66 |
* @static |
|
67 |
* @type boolean |
|
68 | 68 |
*/ |
69 | 69 |
_use_default_post_header:true, |
70 | 70 |
|
71 | 71 |
/** |
72 |
* @description The default header used for POST transactions.
|
|
73 |
* @property _default_post_header
|
|
74 |
* @private
|
|
75 |
* @static
|
|
76 |
* @type boolean
|
|
72 |
* @description The default header used for POST transactions. |
|
73 |
* @property _default_post_header |
|
74 |
* @private |
|
75 |
* @static |
|
76 |
* @type boolean |
|
77 | 77 |
*/ |
78 | 78 |
_default_post_header:'application/x-www-form-urlencoded; charset=UTF-8', |
79 | 79 |
|
80 | 80 |
/** |
81 |
* @description The default header used for transactions involving the
|
|
81 |
* @description The default header used for transactions involving the |
|
82 | 82 |
* use of HTML forms. |
83 |
* @property _default_form_header
|
|
84 |
* @private
|
|
85 |
* @static
|
|
86 |
* @type boolean
|
|
83 |
* @property _default_form_header |
|
84 |
* @private |
|
85 |
* @static |
|
86 |
* @type boolean |
|
87 | 87 |
*/ |
88 | 88 |
_default_form_header:'application/x-www-form-urlencoded', |
89 | 89 |
|
90 | 90 |
/** |
91 |
* @description Determines if a default header of
|
|
91 |
* @description Determines if a default header of |
|
92 | 92 |
* 'X-Requested-With: XMLHttpRequest' |
93 | 93 |
* will be added to each transaction. |
94 |
* @property _use_default_xhr_header
|
|
95 |
* @private
|
|
96 |
* @static
|
|
97 |
* @type boolean
|
|
94 |
* @property _use_default_xhr_header |
|
95 |
* @private |
|
96 |
* @static |
|
97 |
* @type boolean |
|
98 | 98 |
*/ |
99 | 99 |
_use_default_xhr_header:true, |
100 | 100 |
|
101 | 101 |
/** |
102 |
* @description The default header value for the label
|
|
102 |
* @description The default header value for the label |
|
103 | 103 |
* "X-Requested-With". This is sent with each |
104 | 104 |
* transaction, by default, to identify the |
105 | 105 |
* request as being made by YUI Connection Manager. |
106 |
* @property _default_xhr_header
|
|
107 |
* @private
|
|
108 |
* @static
|
|
109 |
* @type boolean
|
|
106 |
* @property _default_xhr_header |
|
107 |
* @private |
|
108 |
* @static |
|
109 |
* @type boolean |
|
110 | 110 |
*/ |
111 | 111 |
_default_xhr_header:'XMLHttpRequest', |
112 | 112 |
|
113 | 113 |
/** |
114 |
* @description Determines if custom, default headers
|
|
114 |
* @description Determines if custom, default headers |
|
115 | 115 |
* are set for each transaction. |
116 |
* @property _has_default_header
|
|
117 |
* @private
|
|
118 |
* @static
|
|
119 |
* @type boolean
|
|
116 |
* @property _has_default_header |
|
117 |
* @private |
|
118 |
* @static |
|
119 |
* @type boolean |
|
120 | 120 |
*/ |
121 | 121 |
_has_default_headers:true, |
122 | 122 |
|
123 | 123 |
/** |
124 |
* @description Determines if custom, default headers
|
|
124 |
* @description Determines if custom, default headers |
|
125 | 125 |
* are set for each transaction. |
126 |
* @property _has_default_header
|
|
127 |
* @private
|
|
128 |
* @static
|
|
129 |
* @type boolean
|
|
126 |
* @property _has_default_header |
|
127 |
* @private |
|
128 |
* @static |
|
129 |
* @type boolean |
|
130 | 130 |
*/ |
131 | 131 |
_default_headers:{}, |
132 | 132 |
|
133 | 133 |
/** |
134 |
* @description Collection of polling references to the polling mechanism in handleReadyState.
|
|
135 |
* @property _poll
|
|
136 |
* @private
|
|
137 |
* @static
|
|
138 |
* @type object
|
|
134 |
* @description Collection of polling references to the polling mechanism in handleReadyState. |
|
135 |
* @property _poll |
|
136 |
* @private |
|
137 |
* @static |
|
138 |
* @type object |
|
139 | 139 |
*/ |
140 | 140 |
_poll:{}, |
141 | 141 |
|
142 | 142 |
/** |
143 |
* @description Queue of timeout values for each transaction callback with a defined timeout value.
|
|
144 |
* @property _timeOut
|
|
145 |
* @private
|
|
146 |
* @static
|
|
147 |
* @type object
|
|
143 |
* @description Queue of timeout values for each transaction callback with a defined timeout value. |
|
144 |
* @property _timeOut |
|
145 |
* @private |
|
146 |
* @static |
|
147 |
* @type object |
|
148 | 148 |
*/ |
149 | 149 |
_timeOut:{}, |
150 | 150 |
|
151 | 151 |
/** |
152 |
* @description The polling frequency, in milliseconds, for HandleReadyState.
|
|
152 |
* @description The polling frequency, in milliseconds, for HandleReadyState. |
|
153 | 153 |
* when attempting to determine a transaction's XHR readyState. |
154 | 154 |
* The default is 50 milliseconds. |
155 |
* @property _polling_interval
|
|
156 |
* @private
|
|
157 |
* @static
|
|
158 |
* @type int
|
|
155 |
* @property _polling_interval |
|
156 |
* @private |
|
157 |
* @static |
|
158 |
* @type int |
|
159 | 159 |
*/ |
160 | 160 |
_polling_interval:50, |
161 | 161 |
|
162 | 162 |
/** |
163 |
* @description A transaction counter that increments the transaction id for each transaction.
|
|
164 |
* @property _transaction_id
|
|
165 |
* @private
|
|
166 |
* @static
|
|
167 |
* @type int
|
|
163 |
* @description A transaction counter that increments the transaction id for each transaction. |
|
164 |
* @property _transaction_id |
|
165 |
* @private |
|
166 |
* @static |
|
167 |
* @type int |
|
168 | 168 |
*/ |
169 | 169 |
_transaction_id:0, |
170 | 170 |
|
171 | 171 |
/** |
172 |
* @description Custom event that fires at the start of a transaction
|
|
173 |
* @property startEvent
|
|
174 |
* @private
|
|
175 |
* @static
|
|
176 |
* @type CustomEvent
|
|
172 |
* @description Custom event that fires at the start of a transaction |
|
173 |
* @property startEvent |
|
174 |
* @private |
|
175 |
* @static |
|
176 |
* @type CustomEvent |
|
177 | 177 |
*/ |
178 | 178 |
startEvent: new YAHOO.util.CustomEvent('start'), |
179 | 179 |
|
180 | 180 |
/** |
181 |
* @description Custom event that fires when a transaction response has completed.
|
|
182 |
* @property completeEvent
|
|
183 |
* @private
|
|
184 |
* @static
|
|
185 |
* @type CustomEvent
|
|
181 |
* @description Custom event that fires when a transaction response has completed. |
|
182 |
* @property completeEvent |
|
183 |
* @private |
|
184 |
* @static |
|
185 |
* @type CustomEvent |
|
186 | 186 |
*/ |
187 | 187 |
completeEvent: new YAHOO.util.CustomEvent('complete'), |
188 | 188 |
|
189 | 189 |
/** |
190 |
* @description Custom event that fires when handleTransactionResponse() determines a
|
|
190 |
* @description Custom event that fires when handleTransactionResponse() determines a |
|
191 | 191 |
* response in the HTTP 2xx range. |
192 |
* @property successEvent
|
|
193 |
* @private
|
|
194 |
* @static
|
|
195 |
* @type CustomEvent
|
|
192 |
* @property successEvent |
|
193 |
* @private |
|
194 |
* @static |
|
195 |
* @type CustomEvent |
|
196 | 196 |
*/ |
197 | 197 |
successEvent: new YAHOO.util.CustomEvent('success'), |
198 | 198 |
|
199 | 199 |
/** |
200 |
* @description Custom event that fires when handleTransactionResponse() determines a
|
|
200 |
* @description Custom event that fires when handleTransactionResponse() determines a |
|
201 | 201 |
* response in the HTTP 4xx/5xx range. |
202 |
* @property failureEvent
|
|
203 |
* @private
|
|
204 |
* @static
|
|
205 |
* @type CustomEvent
|
|
202 |
* @property failureEvent |
|
203 |
* @private |
|
204 |
* @static |
|
205 |
* @type CustomEvent |
|
206 | 206 |
*/ |
207 | 207 |
failureEvent: new YAHOO.util.CustomEvent('failure'), |
208 | 208 |
|
209 | 209 |
/** |
210 |
* @description Custom event that fires when a transaction is successfully aborted.
|
|
211 |
* @property abortEvent
|
|
212 |
* @private
|
|
213 |
* @static
|
|
214 |
* @type CustomEvent
|
|
210 |
* @description Custom event that fires when a transaction is successfully aborted. |
|
211 |
* @property abortEvent |
|
212 |
* @private |
|
213 |
* @static |
|
214 |
* @type CustomEvent |
|
215 | 215 |
*/ |
216 | 216 |
abortEvent: new YAHOO.util.CustomEvent('abort'), |
217 | 217 |
|
218 | 218 |
/** |
219 |
* @description A reference table that maps callback custom events members to its specific
|
|
219 |
* @description A reference table that maps callback custom events members to its specific |
|
220 | 220 |
* event name. |
221 |
* @property _customEvents
|
|
222 |
* @private
|
|
223 |
* @static
|
|
224 |
* @type object
|
|
221 |
* @property _customEvents |
|
222 |
* @private |
|
223 |
* @static |
|
224 |
* @type object |
|
225 | 225 |
*/ |
226 | 226 |
_customEvents: |
227 | 227 |
{ |
... | ... | |
234 | 234 |
}, |
235 | 235 |
|
236 | 236 |
/** |
237 |
* @description Member to add an ActiveX id to the existing xml_progid array.
|
|
237 |
* @description Member to add an ActiveX id to the existing xml_progid array. |
|
238 | 238 |
* In the event(unlikely) a new ActiveX id is introduced, it can be added |
239 | 239 |
* without internal code modifications. |
240 |
* @method setProgId
|
|
241 |
* @public
|
|
242 |
* @static
|
|
243 |
* @param {string} id The ActiveX id to be added to initialize the XHR object.
|
|
244 |
* @return void
|
|
240 |
* @method setProgId |
|
241 |
* @public |
|
242 |
* @static |
|
243 |
* @param {string} id The ActiveX id to be added to initialize the XHR object. |
|
244 |
* @return void |
|
245 | 245 |
*/ |
246 | 246 |
setProgId:function(id) |
247 | 247 |
{ |
... | ... | |
249 | 249 |
}, |
250 | 250 |
|
251 | 251 |
/** |
252 |
* @description Member to override the default POST header.
|
|
253 |
* @method setDefaultPostHeader
|
|
254 |
* @public
|
|
255 |
* @static
|
|
256 |
* @param {boolean} b Set and use default header - true or false .
|
|
257 |
* @return void
|
|
252 |
* @description Member to override the default POST header. |
|
253 |
* @method setDefaultPostHeader |
|
254 |
* @public |
|
255 |
* @static |
|
256 |
* @param {boolean} b Set and use default header - true or false . |
|
257 |
* @return void |
|
258 | 258 |
*/ |
259 | 259 |
setDefaultPostHeader:function(b) |
260 | 260 |
{ |
... | ... | |
267 | 267 |
}, |
268 | 268 |
|
269 | 269 |
/** |
270 |
* @description Member to override the default transaction header..
|
|
271 |
* @method setDefaultXhrHeader
|
|
272 |
* @public
|
|
273 |
* @static
|
|
274 |
* @param {boolean} b Set and use default header - true or false .
|
|
275 |
* @return void
|
|
270 |
* @description Member to override the default transaction header.. |
|
271 |
* @method setDefaultXhrHeader |
|
272 |
* @public |
|
273 |
* @static |
|
274 |
* @param {boolean} b Set and use default header - true or false . |
|
275 |
* @return void |
|
276 | 276 |
*/ |
277 | 277 |
setDefaultXhrHeader:function(b) |
278 | 278 |
{ |
... | ... | |
285 | 285 |
}, |
286 | 286 |
|
287 | 287 |
/** |
288 |
* @description Member to modify the default polling interval.
|
|
289 |
* @method setPollingInterval
|
|
290 |
* @public
|
|
291 |
* @static
|
|
292 |
* @param {int} i The polling interval in milliseconds.
|
|
293 |
* @return void
|
|
288 |
* @description Member to modify the default polling interval. |
|
289 |
* @method setPollingInterval |
|
290 |
* @public |
|
291 |
* @static |
|
292 |
* @param {int} i The polling interval in milliseconds. |
|
293 |
* @return void |
|
294 | 294 |
*/ |
295 | 295 |
setPollingInterval:function(i) |
296 | 296 |
{ |
... | ... | |
300 | 300 |
}, |
301 | 301 |
|
302 | 302 |
/** |
303 |
* @description Instantiates a XMLHttpRequest object and returns an object with two properties:
|
|
303 |
* @description Instantiates a XMLHttpRequest object and returns an object with two properties: |
|
304 | 304 |
* the XMLHttpRequest instance and the transaction id. |
305 |
* @method createXhrObject
|
|
306 |
* @private
|
|
307 |
* @static
|
|
308 |
* @param {int} transactionId Property containing the transaction id for this transaction.
|
|
309 |
* @return object
|
|
305 |
* @method createXhrObject |
|
306 |
* @private |
|
307 |
* @static |
|
308 |
* @param {int} transactionId Property containing the transaction id for this transaction. |
|
309 |
* @return object |
|
310 | 310 |
*/ |
311 | 311 |
createXhrObject:function(transactionId) |
312 | 312 |
{ |
... | ... | |
339 | 339 |
}, |
340 | 340 |
|
341 | 341 |
/** |
342 |
* @description This method is called by asyncRequest to create a
|
|
342 |
* @description This method is called by asyncRequest to create a |
|
343 | 343 |
* valid connection object for the transaction. It also passes a |
344 | 344 |
* transaction id and increments the transaction id counter. |
345 |
* @method getConnectionObject
|
|
346 |
* @private
|
|
347 |
* @static
|
|
348 |
* @return {object}
|
|
345 |
* @method getConnectionObject |
|
346 |
* @private |
|
347 |
* @static |
|
348 |
* @return {object} |
|
349 | 349 |
*/ |
350 | 350 |
getConnectionObject:function(t) |
351 | 351 |
{ |
... | ... | |
376 | 376 |
}, |
377 | 377 |
|
378 | 378 |
/** |
379 |
* @description Method for initiating an asynchronous request via the XHR object.
|
|
380 |
* @method asyncRequest
|
|
381 |
* @public
|
|
382 |
* @static
|
|
383 |
* @param {string} method HTTP transaction method
|
|
384 |
* @param {string} uri Fully qualified path of resource
|
|
385 |
* @param {callback} callback User-defined callback function or object
|
|
386 |
* @param {string} postData POST body
|
|
387 |
* @return {object} Returns the connection object
|
|
379 |
* @description Method for initiating an asynchronous request via the XHR object. |
|
380 |
* @method asyncRequest |
|
381 |
* @public |
|
382 |
* @static |
|
383 |
* @param {string} method HTTP transaction method |
|
384 |
* @param {string} uri Fully qualified path of resource |
|
385 |
* @param {callback} callback User-defined callback function or object |
|
386 |
* @param {string} postData POST body |
|
387 |
* @return {object} Returns the connection object |
|
388 | 388 |
*/ |
389 | 389 |
asyncRequest:function(method, uri, callback, postData) |
390 | 390 |
{ |
... | ... | |
485 | 485 |
}, |
486 | 486 |
|
487 | 487 |
/** |
488 |
* @description This method creates and subscribes custom events,
|
|
488 |
* @description This method creates and subscribes custom events, |
|
489 | 489 |
* specific to each transaction |
490 |
* @method initCustomEvents
|
|
491 |
* @private
|
|
492 |
* @static
|
|
493 |
* @param {object} o The connection object
|
|
494 |
* @param {callback} callback The user-defined callback object
|
|
495 |
* @return {void}
|
|
490 |
* @method initCustomEvents |
|
491 |
* @private |
|
492 |
* @static |
|
493 |
* @param {object} o The connection object |
|
494 |
* @param {callback} callback The user-defined callback object |
|
495 |
* @return {void} |
|
496 | 496 |
*/ |
497 | 497 |
initCustomEvents:function(o, callback) |
498 | 498 |
{ |
... | ... | |
511 | 511 |
}, |
512 | 512 |
|
513 | 513 |
/** |
514 |
* @description This method serves as a timer that polls the XHR object's readyState
|
|
514 |
* @description This method serves as a timer that polls the XHR object's readyState |
|
515 | 515 |
* property during a transaction, instead of binding a callback to the |
516 | 516 |
* onreadystatechange event. Upon readyState 4, handleTransactionResponse |
517 | 517 |
* will process the response, and the timer will be cleared. |
518 |
* @method handleReadyState
|
|
519 |
* @private
|
|
520 |
* @static
|
|
521 |
* @param {object} o The connection object
|
|
522 |
* @param {callback} callback The user-defined callback object
|
|
523 |
* @return {void}
|
|
518 |
* @method handleReadyState |
|
519 |
* @private |
|
520 |
* @static |
|
521 |
* @param {object} o The connection object |
|
522 |
* @param {callback} callback The user-defined callback object |
|
523 |
* @return {void} |
|
524 | 524 |
*/ |
525 | 525 |
|
526 | 526 |
handleReadyState:function(o, callback) |
... | ... | |
562 | 562 |
}, |
563 | 563 |
|
564 | 564 |
/** |
565 |
* @description This method attempts to interpret the server response and
|
|
565 |
* @description This method attempts to interpret the server response and |
|
566 | 566 |
* determine whether the transaction was successful, or if an error or |
567 | 567 |
* exception was encountered. |
568 |
* @method handleTransactionResponse
|
|
569 |
* @private
|
|
570 |
* @static
|
|
571 |
* @param {object} o The connection object
|
|
572 |
* @param {object} callback The user-defined callback object
|
|
573 |
* @param {boolean} isAbort Determines if the transaction was terminated via abort().
|
|
574 |
* @return {void}
|
|
568 |
* @method handleTransactionResponse |
|
569 |
* @private |
|
570 |
* @static |
|
571 |
* @param {object} o The connection object |
|
572 |
* @param {object} callback The user-defined callback object |
|
573 |
* @param {boolean} isAbort Determines if the transaction was terminated via abort(). |
|
574 |
* @return {void} |
|
575 | 575 |
*/ |
576 | 576 |
handleTransactionResponse:function(o, callback, isAbort) |
577 | 577 |
{ |
... | ... | |
676 | 676 |
}, |
677 | 677 |
|
678 | 678 |
/** |
679 |
* @description This method evaluates the server response, creates and returns the results via
|
|
679 |
* @description This method evaluates the server response, creates and returns the results via |
|
680 | 680 |
* its properties. Success and failure cases will differ in the response |
681 | 681 |
* object's property values. |
682 |
* @method createResponseObject
|
|
683 |
* @private
|
|
684 |
* @static
|
|
685 |
* @param {object} o The connection object
|
|
686 |
* @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback
|
|
687 |
* @return {object}
|
|
682 |
* @method createResponseObject |
|
683 |
* @private |
|
684 |
* @static |
|
685 |
* @param {object} o The connection object |
|
686 |
* @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback |
|
687 |
* @return {object} |
|
688 | 688 |
*/ |
689 | 689 |
createResponseObject:function(o, callbackArg) |
690 | 690 |
{ |
... | ... | |
722 | 722 |
}, |
723 | 723 |
|
724 | 724 |
/** |
725 |
* @description If a transaction cannot be completed due to dropped or closed connections,
|
|
725 |
* @description If a transaction cannot be completed due to dropped or closed connections, |
|
726 | 726 |
* there may be not be enough information to build a full response object. |
727 | 727 |
* The failure callback will be fired and this specific condition can be identified |
728 | 728 |
* by a status property value of 0. |
729 | 729 |
* |
730 | 730 |
* If an abort was successful, the status property will report a value of -1. |
731 | 731 |
* |
732 |
* @method createExceptionObject
|
|
733 |
* @private
|
|
734 |
* @static
|
|
735 |
* @param {int} tId The Transaction Id
|
|
736 |
* @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback
|
|
737 |
* @param {boolean} isAbort Determines if the exception case is caused by a transaction abort
|
|
738 |
* @return {object}
|
|
732 |
* @method createExceptionObject |
|
733 |
* @private |
|
734 |
* @static |
|
735 |
* @param {int} tId The Transaction Id |
|
736 |
* @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback |
|
737 |
* @param {boolean} isAbort Determines if the exception case is caused by a transaction abort |
|
738 |
* @return {object} |
|
739 | 739 |
*/ |
740 | 740 |
createExceptionObject:function(tId, callbackArg, isAbort) |
741 | 741 |
{ |
... | ... | |
763 | 763 |
}, |
764 | 764 |
|
765 | 765 |
/** |
766 |
* @description Method that initializes the custom HTTP headers for the each transaction.
|
|
767 |
* @method initHeader
|
|
768 |
* @public
|
|
769 |
* @static
|
|
770 |
* @param {string} label The HTTP header label
|
|
771 |
* @param {string} value The HTTP header value
|
|
772 |
* @param {string} isDefault Determines if the specific header is a default header
|
|
766 |
* @description Method that initializes the custom HTTP headers for the each transaction. |
|
767 |
* @method initHeader |
|
768 |
* @public |
|
769 |
* @static |
|
770 |
* @param {string} label The HTTP header label |
|
771 |
* @param {string} value The HTTP header value |
|
772 |
* @param {string} isDefault Determines if the specific header is a default header |
|
773 | 773 |
* automatically sent with each transaction. |
774 |
* @return {void}
|
|
774 |
* @return {void} |
|
775 | 775 |
*/ |
776 | 776 |
initHeader:function(label, value, isDefault) |
777 | 777 |
{ |
... | ... | |
788 | 788 |
|
789 | 789 |
|
790 | 790 |
/** |
791 |
* @description Accessor that sets the HTTP headers for each transaction.
|
|
792 |
* @method setHeader
|
|
793 |
* @private
|
|
794 |
* @static
|
|
795 |
* @param {object} o The connection object for the transaction.
|
|
796 |
* @return {void}
|
|
791 |
* @description Accessor that sets the HTTP headers for each transaction. |
|
792 |
* @method setHeader |
|
793 |
* @private |
|
794 |
* @static |
|
795 |
* @param {object} o The connection object for the transaction. |
|
796 |
* @return {void} |
|
797 | 797 |
*/ |
798 | 798 |
setHeader:function(o) |
799 | 799 |
{ |
... | ... | |
819 | 819 |
}, |
820 | 820 |
|
821 | 821 |
/** |
822 |
* @description Resets the default HTTP headers object
|
|
823 |
* @method resetDefaultHeaders
|
|
824 |
* @public
|
|
825 |
* @static
|
|
826 |
* @return {void}
|
|
822 |
* @description Resets the default HTTP headers object |
|
823 |
* @method resetDefaultHeaders |
|
824 |
* @public |
|
825 |
* @static |
|
826 |
* @return {void} |
|
827 | 827 |
*/ |
828 | 828 |
resetDefaultHeaders:function(){ |
829 | 829 |
this._default_headers = {}; |
... | ... | |
831 | 831 |
}, |
832 | 832 |
|
833 | 833 |
/** |
834 |
* @description Method to terminate a transaction, if it has not reached readyState 4.
|
|
835 |
* @method abort
|
|
836 |
* @public
|
|
837 |
* @static
|
|
838 |
* @param {object} o The connection object returned by asyncRequest.
|
|
839 |
* @param {object} callback User-defined callback object.
|
|
840 |
* @param {string} isTimeout boolean to indicate if abort resulted from a callback timeout.
|
|
841 |
* @return {boolean}
|
|
834 |
* @description Method to terminate a transaction, if it has not reached readyState 4. |
|
835 |
* @method abort |
|
836 |
* @public |
|
837 |
* @static |
|
838 |
* @param {object} o The connection object returned by asyncRequest. |
|
839 |
* @param {object} callback User-defined callback object. |
|
840 |
* @param {string} isTimeout boolean to indicate if abort resulted from a callback timeout. |
|
841 |
* @return {boolean} |
|
842 | 842 |
*/ |
843 | 843 |
abort:function(o, callback, isTimeout) |
844 | 844 |
{ |
... | ... | |
907 | 907 |
}, |
908 | 908 |
|
909 | 909 |
/** |
910 |
* @description Determines if the transaction is still being processed.
|
|
911 |
* @method isCallInProgress
|
|
912 |
* @public
|
|
913 |
* @static
|
|
914 |
* @param {object} o The connection object returned by asyncRequest
|
|
915 |
* @return {boolean}
|
|
910 |
* @description Determines if the transaction is still being processed. |
|
911 |
* @method isCallInProgress |
|
912 |
* @public |
|
913 |
* @static |
|
914 |
* @param {object} o The connection object returned by asyncRequest |
|
915 |
* @return {boolean} |
|
916 | 916 |
*/ |
917 | 917 |
isCallInProgress:function(o) |
918 | 918 |
{ |
... | ... | |
934 | 934 |
}, |
935 | 935 |
|
936 | 936 |
/** |
937 |
* @description Dereference the XHR instance and the connection object after the transaction is completed.
|
|
938 |
* @method releaseObject
|
|
939 |
* @private
|
|
940 |
* @static
|
|
941 |
* @param {object} o The connection object
|
|
942 |
* @return {void}
|
|
937 |
* @description Dereference the XHR instance and the connection object after the transaction is completed. |
|
938 |
* @method releaseObject |
|
939 |
* @private |
|
940 |
* @static |
|
941 |
* @param {object} o The connection object |
|
942 |
* @return {void} |
|
943 | 943 |
*/ |
944 | 944 |
releaseObject:function(o) |
945 | 945 |
{ |
... | ... | |
955 | 955 |
}; |
956 | 956 |
|
957 | 957 |
/** |
958 |
* @for Connect
|
|
958 |
* @for Connect |
|
959 | 959 |
*/ |
960 | 960 |
(function() { |
961 | 961 |
var YCM = YAHOO.util.Connect, _fn = {}; |
962 | 962 |
|
963 | 963 |
/** |
964 |
* @description This method creates and instantiates the Flash transport.
|
|
965 |
* @method _swf
|
|
966 |
* @private
|
|
967 |
* @static
|
|
968 |
* @param {string} URI to connection.swf.
|
|
969 |
* @return {void}
|
|
964 |
* @description This method creates and instantiates the Flash transport. |
|
965 |
* @method _swf |
|
966 |
* @private |
|
967 |
* @static |
|
968 |
* @param {string} URI to connection.swf. |
|
969 |
* @return {void} |
|
970 | 970 |
*/ |
971 | 971 |
function _swf(uri) { |
972 | 972 |
var o = '<object id="YUIConnectionSwf" type="application/x-shockwave-flash" data="' + |
... | ... | |
981 | 981 |
} |
982 | 982 |
|
983 | 983 |
/** |
984 |
* @description This method calls the public method on the
|
|
984 |
* @description This method calls the public method on the |
|
985 | 985 |
* Flash transport to start the XDR transaction. It is analogous |
986 | 986 |
* to Connection Manager's asyncRequest method. |
987 |
* @method xdr
|
|
988 |
* @private
|
|
989 |
* @static
|
|
990 |
* @param {object} The transaction object.
|
|
991 |
* @param {string} HTTP request method.
|
|
992 |
* @param {string} URI for the transaction.
|
|
993 |
* @param {object} The transaction's callback object.
|
|
994 |
* @param {object} The JSON object used as HTTP POST data.
|
|
995 |
* @return {void}
|
|
987 |
* @method xdr |
|
988 |
* @private |
|
989 |
* @static |
|
990 |
* @param {object} The transaction object. |
|
991 |
* @param {string} HTTP request method. |
|
992 |
* @param {string} URI for the transaction. |
|
993 |
* @param {object} The transaction's callback object. |
|
994 |
* @param {object} The JSON object used as HTTP POST data. |
|
995 |
* @return {void} |
|
996 | 996 |
*/ |
997 | 997 |
function _xdr(o, m, u, c, d) { |
998 | 998 |
_fn[parseInt(o.tId)] = { 'o':o, 'c':c }; |
... | ... | |
1005 | 1005 |
} |
1006 | 1006 |
|
1007 | 1007 |
/** |
1008 |
* @description This method instantiates the Flash transport and
|
|
1008 |
* @description This method instantiates the Flash transport and |
|
1009 | 1009 |
* establishes a static reference to it, used for all XDR requests. |
1010 |
* @method transport
|
|
1011 |
* @public
|
|
1012 |
* @static
|
|
1013 |
* @param {string} URI to connection.swf.
|
|
1014 |
* @return {void}
|
|
1010 |
* @method transport |
|
1011 |
* @public |
|
1012 |
* @static |
|
1013 |
* @param {string} URI to connection.swf. |
|
1014 |
* @return {void} |
|
1015 | 1015 |
*/ |
1016 | 1016 |
function _init(uri) { |
1017 | 1017 |
_swf(uri); |
... | ... | |
1023 | 1023 |
} |
1024 | 1024 |
|
1025 | 1025 |
/** |
1026 |
* @description This method fires the global and transaction start
|
|
1026 |
* @description This method fires the global and transaction start |
|
1027 | 1027 |
* events. |
1028 |
* @method _xdrStart
|
|
1029 |
* @private
|
|
1030 |
* @static
|
|
1031 |
* @param {object} The transaction object.
|
|
1032 |
* @param {string} The transaction's callback object.
|
|
1033 |
* @return {void}
|
|
1028 |
* @method _xdrStart |
|
1029 |
* @private |
|
1030 |
* @static |
|
1031 |
* @param {object} The transaction object. |
|
1032 |
* @param {string} The transaction's callback object. |
|
1033 |
* @return {void} |
|
1034 | 1034 |
*/ |
1035 | 1035 |
function _xdrStart(o, cb) { |
1036 | 1036 |
if (o) { |
... | ... | |
1045 | 1045 |
} |
1046 | 1046 |
|
1047 | 1047 |
/** |
1048 |
* @description This method is the initial response handler
|
|
1048 |
* @description This method is the initial response handler |
|
1049 | 1049 |
* for XDR transactions. The Flash transport calls this |
1050 | 1050 |
* function and sends the response payload. |
1051 |
* @method handleXdrResponse
|
|
1052 |
* @private
|
|
1053 |
* @static
|
|
1054 |
* @param {object} The response object sent from the Flash transport.
|
|
1055 |
* @return {void}
|
|
1051 |
* @method handleXdrResponse |
|
1052 |
* @private |
|
1053 |
* @static |
|
1054 |
* @param {object} The response object sent from the Flash transport. |
|
1055 |
* @return {void} |
|
1056 | 1056 |
*/ |
1057 | 1057 |
function _handleXdrResponse(r) { |
1058 | 1058 |
var o = _fn[r.tId].o, |
... | ... | |
1083 | 1083 |
})(); |
1084 | 1084 |
|
1085 | 1085 |
/** |
1086 |
* @for Connect
|
|
1086 |
* @for Connect |
|
1087 | 1087 |
*/ |
1088 | 1088 |
(function(){ |
1089 | 1089 |
var YCM = YAHOO.util.Connect, |
... | ... | |
1139 | 1139 |
YCM._submitElementValue = null; |
1140 | 1140 |
|
1141 | 1141 |
/** |
1142 |
* @description Custom event that fires when handleTransactionResponse() determines a
|
|
1142 |
* @description Custom event that fires when handleTransactionResponse() determines a |
|
1143 | 1143 |
* response in the HTTP 4xx/5xx range. |
1144 |
* @property failureEvent
|
|
1145 |
* @private
|
|
1146 |
* @static
|
|
1147 |
* @type CustomEvent
|
|
1144 |
* @property failureEvent |
|
1145 |
* @private |
|
1146 |
* @static |
|
1147 |
* @type CustomEvent |
|
1148 | 1148 |
*/ |
1149 | 1149 |
YCM.uploadEvent = new YAHOO.util.CustomEvent('upload'), |
1150 | 1150 |
|
... | ... | |
1176 | 1176 |
}(); |
1177 | 1177 |
|
1178 | 1178 |
/** |
1179 |
* @description This method assembles the form label and value pairs and
|
|
1179 |
* @description This method assembles the form label and value pairs and |
|
1180 | 1180 |
* constructs an encoded string. |
1181 | 1181 |
* asyncRequest() will automatically initialize the transaction with a |
1182 | 1182 |
* a HTTP header Content-Type of application/x-www-form-urlencoded. |
1183 |
* @method setForm
|
|
1184 |
* @public
|
|
1185 |
* @static
|
|
1186 |
* @param {string || object} form id or name attribute, or form object.
|
|
1187 |
* @param {boolean} optional enable file upload.
|
|
1188 |
* @param {boolean} optional enable file upload over SSL in IE only.
|
|
1189 |
* @return {string} string of the HTML form field name and value pairs..
|
|
1183 |
* @method setForm |
|
1184 |
* @public |
|
1185 |
* @static |
|
1186 |
* @param {string || object} form id or name attribute, or form object. |
|
1187 |
* @param {boolean} optional enable file upload. |
|
1188 |
* @param {boolean} optional enable file upload over SSL in IE only. |
|
1189 |
* @return {string} string of the HTML form field name and value pairs.. |
|
1190 | 1190 |
*/ |
1191 | 1191 |
function _setForm(formId, isUpload, secureUri) |
1192 | 1192 |
{ |
... | ... | |
1305 | 1305 |
} |
1306 | 1306 |
|
1307 | 1307 |
/** |
1308 |
* @description Resets HTML form properties when an HTML form or HTML form
|
|
1308 |
* @description Resets HTML form properties when an HTML form or HTML form |
|
1309 | 1309 |
* with file upload transaction is sent. |
1310 |
* @method resetFormState
|
|
1311 |
* @private
|
|
1312 |
* @static
|
|
1313 |
* @return {void}
|
|
1310 |
* @method resetFormState |
|
1311 |
* @private |
|
1312 |
* @static |
|
1313 |
* @return {void} |
|
1314 | 1314 |
*/ |
1315 | 1315 |
function _resetFormState(){ |
1316 | 1316 |
this._isFormSubmit = false; |
... | ... | |
1321 | 1321 |
|
1322 | 1322 |
|
1323 | 1323 |
/** |
1324 |
* @description Creates an iframe to be used for form file uploads. It is remove from the
|
|
1324 |
* @description Creates an iframe to be used for form file uploads. It is remove from the |
|
1325 | 1325 |
* document upon completion of the upload transaction. |
1326 |
* @method createFrame
|
|
1327 |
* @private
|
|
1328 |
* @static
|
|
1329 |
* @param {string} optional qualified path of iframe resource for SSL in IE.
|
|
1330 |
* @return {void}
|
|
1326 |
* @method createFrame |
|
1327 |
* @private |
|
1328 |
* @static |
|
1329 |
* @param {string} optional qualified path of iframe resource for SSL in IE. |
|
1330 |
* @return {void} |
|
1331 | 1331 |
*/ |
1332 | 1332 |
function _createFrame(secureUri){ |
1333 | 1333 |
|
... | ... | |
1359 | 1359 |
} |
1360 | 1360 |
|
1361 | 1361 |
/** |
1362 |
* @description Parses the POST data and creates hidden form elements
|
|
1362 |
* @description Parses the POST data and creates hidden form elements |
|
1363 | 1363 |
* for each key-value, and appends them to the HTML form object. |
1364 |
* @method appendPostData
|
|
1365 |
* @private
|
|
1366 |
* @static
|
|
1367 |
* @param {string} postData The HTTP POST data
|
|
1368 |
* @return {array} formElements Collection of hidden fields.
|
|
1364 |
* @method appendPostData |
|
1365 |
* @private |
|
1366 |
* @static |
|
1367 |
* @param {string} postData The HTTP POST data |
|
1368 |
* @return {array} formElements Collection of hidden fields. |
|
1369 | 1369 |
*/ |
1370 | 1370 |
function _appendPostData(postData){ |
1371 | 1371 |
var formElements = [], |
... | ... | |
1387 | 1387 |
} |
1388 | 1388 |
|
1389 | 1389 |
/** |
1390 |
* @description Uploads HTML form, inclusive of files/attachments, using the
|
|
1390 |
* @description Uploads HTML form, inclusive of files/attachments, using the |
|
1391 | 1391 |
* iframe created in createFrame to facilitate the transaction. |
1392 |
* @method uploadFile
|
|
1393 |
* @private
|
|
1394 |
* @static
|
|
1395 |
* @param {int} id The transaction id.
|
|
1396 |
* @param {object} callback User-defined callback object.
|
|
1397 |
* @param {string} uri Fully qualified path of resource.
|
|
1398 |
* @param {string} postData POST data to be submitted in addition to HTML form.
|
|
1399 |
* @return {void}
|
|
1392 |
* @method uploadFile |
|
1393 |
* @private |
|
1394 |
* @static |
|
1395 |
* @param {int} id The transaction id. |
|
1396 |
* @param {object} callback User-defined callback object. |
|
1397 |
* @param {string} uri Fully qualified path of resource. |
|
1398 |
* @param {string} postData POST data to be submitted in addition to HTML form. |
|
1399 |
* @return {void} |
|
1400 | 1400 |
*/ |
1401 | 1401 |
function _uploadFile(o, callback, uri, postData){ |
1402 | 1402 |
// Each iframe has an id prefix of "yuiIO" followed |
Also available in: Unified diff
fixed headerinfos