Revision 1374
Added by Dietmar over 13 years ago
connection-debug.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 |
{ |
... | ... | |
250 | 250 |
}, |
251 | 251 |
|
252 | 252 |
/** |
253 |
* @description Member to override the default POST header.
|
|
254 |
* @method setDefaultPostHeader
|
|
255 |
* @public
|
|
256 |
* @static
|
|
257 |
* @param {boolean} b Set and use default header - true or false .
|
|
258 |
* @return void
|
|
253 |
* @description Member to override the default POST header. |
|
254 |
* @method setDefaultPostHeader |
|
255 |
* @public |
|
256 |
* @static |
|
257 |
* @param {boolean} b Set and use default header - true or false . |
|
258 |
* @return void |
|
259 | 259 |
*/ |
260 | 260 |
setDefaultPostHeader:function(b) |
261 | 261 |
{ |
... | ... | |
269 | 269 |
}, |
270 | 270 |
|
271 | 271 |
/** |
272 |
* @description Member to override the default transaction header..
|
|
273 |
* @method setDefaultXhrHeader
|
|
274 |
* @public
|
|
275 |
* @static
|
|
276 |
* @param {boolean} b Set and use default header - true or false .
|
|
277 |
* @return void
|
|
272 |
* @description Member to override the default transaction header.. |
|
273 |
* @method setDefaultXhrHeader |
|
274 |
* @public |
|
275 |
* @static |
|
276 |
* @param {boolean} b Set and use default header - true or false . |
|
277 |
* @return void |
|
278 | 278 |
*/ |
279 | 279 |
setDefaultXhrHeader:function(b) |
280 | 280 |
{ |
... | ... | |
288 | 288 |
}, |
289 | 289 |
|
290 | 290 |
/** |
291 |
* @description Member to modify the default polling interval.
|
|
292 |
* @method setPollingInterval
|
|
293 |
* @public
|
|
294 |
* @static
|
|
295 |
* @param {int} i The polling interval in milliseconds.
|
|
296 |
* @return void
|
|
291 |
* @description Member to modify the default polling interval. |
|
292 |
* @method setPollingInterval |
|
293 |
* @public |
|
294 |
* @static |
|
295 |
* @param {int} i The polling interval in milliseconds. |
|
296 |
* @return void |
|
297 | 297 |
*/ |
298 | 298 |
setPollingInterval:function(i) |
299 | 299 |
{ |
... | ... | |
304 | 304 |
}, |
305 | 305 |
|
306 | 306 |
/** |
307 |
* @description Instantiates a XMLHttpRequest object and returns an object with two properties:
|
|
307 |
* @description Instantiates a XMLHttpRequest object and returns an object with two properties: |
|
308 | 308 |
* the XMLHttpRequest instance and the transaction id. |
309 |
* @method createXhrObject
|
|
310 |
* @private
|
|
311 |
* @static
|
|
312 |
* @param {int} transactionId Property containing the transaction id for this transaction.
|
|
313 |
* @return object
|
|
309 |
* @method createXhrObject |
|
310 |
* @private |
|
311 |
* @static |
|
312 |
* @param {int} transactionId Property containing the transaction id for this transaction. |
|
313 |
* @return object |
|
314 | 314 |
*/ |
315 | 315 |
createXhrObject:function(transactionId) |
316 | 316 |
{ |
... | ... | |
345 | 345 |
}, |
346 | 346 |
|
347 | 347 |
/** |
348 |
* @description This method is called by asyncRequest to create a
|
|
348 |
* @description This method is called by asyncRequest to create a |
|
349 | 349 |
* valid connection object for the transaction. It also passes a |
350 | 350 |
* transaction id and increments the transaction id counter. |
351 |
* @method getConnectionObject
|
|
352 |
* @private
|
|
353 |
* @static
|
|
354 |
* @return {object}
|
|
351 |
* @method getConnectionObject |
|
352 |
* @private |
|
353 |
* @static |
|
354 |
* @return {object} |
|
355 | 355 |
*/ |
356 | 356 |
getConnectionObject:function(t) |
357 | 357 |
{ |
... | ... | |
382 | 382 |
}, |
383 | 383 |
|
384 | 384 |
/** |
385 |
* @description Method for initiating an asynchronous request via the XHR object.
|
|
386 |
* @method asyncRequest
|
|
387 |
* @public
|
|
388 |
* @static
|
|
389 |
* @param {string} method HTTP transaction method
|
|
390 |
* @param {string} uri Fully qualified path of resource
|
|
391 |
* @param {callback} callback User-defined callback function or object
|
|
392 |
* @param {string} postData POST body
|
|
393 |
* @return {object} Returns the connection object
|
|
385 |
* @description Method for initiating an asynchronous request via the XHR object. |
|
386 |
* @method asyncRequest |
|
387 |
* @public |
|
388 |
* @static |
|
389 |
* @param {string} method HTTP transaction method |
|
390 |
* @param {string} uri Fully qualified path of resource |
|
391 |
* @param {callback} callback User-defined callback function or object |
|
392 |
* @param {string} postData POST body |
|
393 |
* @return {object} Returns the connection object |
|
394 | 394 |
*/ |
395 | 395 |
asyncRequest:function(method, uri, callback, postData) |
396 | 396 |
{ |
... | ... | |
495 | 495 |
}, |
496 | 496 |
|
497 | 497 |
/** |
498 |
* @description This method creates and subscribes custom events,
|
|
498 |
* @description This method creates and subscribes custom events, |
|
499 | 499 |
* specific to each transaction |
500 |
* @method initCustomEvents
|
|
501 |
* @private
|
|
502 |
* @static
|
|
503 |
* @param {object} o The connection object
|
|
504 |
* @param {callback} callback The user-defined callback object
|
|
505 |
* @return {void}
|
|
500 |
* @method initCustomEvents |
|
501 |
* @private |
|
502 |
* @static |
|
503 |
* @param {object} o The connection object |
|
504 |
* @param {callback} callback The user-defined callback object |
|
505 |
* @return {void} |
|
506 | 506 |
*/ |
507 | 507 |
initCustomEvents:function(o, callback) |
508 | 508 |
{ |
... | ... | |
523 | 523 |
}, |
524 | 524 |
|
525 | 525 |
/** |
526 |
* @description This method serves as a timer that polls the XHR object's readyState
|
|
526 |
* @description This method serves as a timer that polls the XHR object's readyState |
|
527 | 527 |
* property during a transaction, instead of binding a callback to the |
528 | 528 |
* onreadystatechange event. Upon readyState 4, handleTransactionResponse |
529 | 529 |
* will process the response, and the timer will be cleared. |
530 |
* @method handleReadyState
|
|
531 |
* @private
|
|
532 |
* @static
|
|
533 |
* @param {object} o The connection object
|
|
534 |
* @param {callback} callback The user-defined callback object
|
|
535 |
* @return {void}
|
|
530 |
* @method handleReadyState |
|
531 |
* @private |
|
532 |
* @static |
|
533 |
* @param {object} o The connection object |
|
534 |
* @param {callback} callback The user-defined callback object |
|
535 |
* @return {void} |
|
536 | 536 |
*/ |
537 | 537 |
|
538 | 538 |
handleReadyState:function(o, callback) |
... | ... | |
574 | 574 |
}, |
575 | 575 |
|
576 | 576 |
/** |
577 |
* @description This method attempts to interpret the server response and
|
|
577 |
* @description This method attempts to interpret the server response and |
|
578 | 578 |
* determine whether the transaction was successful, or if an error or |
579 | 579 |
* exception was encountered. |
580 |
* @method handleTransactionResponse
|
|
581 |
* @private
|
|
582 |
* @static
|
|
583 |
* @param {object} o The connection object
|
|
584 |
* @param {object} callback The user-defined callback object
|
|
585 |
* @param {boolean} isAbort Determines if the transaction was terminated via abort().
|
|
586 |
* @return {void}
|
|
580 |
* @method handleTransactionResponse |
|
581 |
* @private |
|
582 |
* @static |
|
583 |
* @param {object} o The connection object |
|
584 |
* @param {object} callback The user-defined callback object |
|
585 |
* @param {boolean} isAbort Determines if the transaction was terminated via abort(). |
|
586 |
* @return {void} |
|
587 | 587 |
*/ |
588 | 588 |
handleTransactionResponse:function(o, callback, isAbort) |
589 | 589 |
{ |
... | ... | |
694 | 694 |
}, |
695 | 695 |
|
696 | 696 |
/** |
697 |
* @description This method evaluates the server response, creates and returns the results via
|
|
697 |
* @description This method evaluates the server response, creates and returns the results via |
|
698 | 698 |
* its properties. Success and failure cases will differ in the response |
699 | 699 |
* object's property values. |
700 |
* @method createResponseObject
|
|
701 |
* @private
|
|
702 |
* @static
|
|
703 |
* @param {object} o The connection object
|
|
704 |
* @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback
|
|
705 |
* @return {object}
|
|
700 |
* @method createResponseObject |
|
701 |
* @private |
|
702 |
* @static |
|
703 |
* @param {object} o The connection object |
|
704 |
* @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback |
|
705 |
* @return {object} |
|
706 | 706 |
*/ |
707 | 707 |
createResponseObject:function(o, callbackArg) |
708 | 708 |
{ |
... | ... | |
740 | 740 |
}, |
741 | 741 |
|
742 | 742 |
/** |
743 |
* @description If a transaction cannot be completed due to dropped or closed connections,
|
|
743 |
* @description If a transaction cannot be completed due to dropped or closed connections, |
|
744 | 744 |
* there may be not be enough information to build a full response object. |
745 | 745 |
* The failure callback will be fired and this specific condition can be identified |
746 | 746 |
* by a status property value of 0. |
747 | 747 |
* |
748 | 748 |
* If an abort was successful, the status property will report a value of -1. |
749 | 749 |
* |
750 |
* @method createExceptionObject
|
|
751 |
* @private
|
|
752 |
* @static
|
|
753 |
* @param {int} tId The Transaction Id
|
|
754 |
* @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback
|
|
755 |
* @param {boolean} isAbort Determines if the exception case is caused by a transaction abort
|
|
756 |
* @return {object}
|
|
750 |
* @method createExceptionObject |
|
751 |
* @private |
|
752 |
* @static |
|
753 |
* @param {int} tId The Transaction Id |
|
754 |
* @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback |
|
755 |
* @param {boolean} isAbort Determines if the exception case is caused by a transaction abort |
|
756 |
* @return {object} |
|
757 | 757 |
*/ |
758 | 758 |
createExceptionObject:function(tId, callbackArg, isAbort) |
759 | 759 |
{ |
... | ... | |
781 | 781 |
}, |
782 | 782 |
|
783 | 783 |
/** |
784 |
* @description Method that initializes the custom HTTP headers for the each transaction.
|
|
785 |
* @method initHeader
|
|
786 |
* @public
|
|
787 |
* @static
|
|
788 |
* @param {string} label The HTTP header label
|
|
789 |
* @param {string} value The HTTP header value
|
|
790 |
* @param {string} isDefault Determines if the specific header is a default header
|
|
784 |
* @description Method that initializes the custom HTTP headers for the each transaction. |
|
785 |
* @method initHeader |
|
786 |
* @public |
|
787 |
* @static |
|
788 |
* @param {string} label The HTTP header label |
|
789 |
* @param {string} value The HTTP header value |
|
790 |
* @param {string} isDefault Determines if the specific header is a default header |
|
791 | 791 |
* automatically sent with each transaction. |
792 |
* @return {void}
|
|
792 |
* @return {void} |
|
793 | 793 |
*/ |
794 | 794 |
initHeader:function(label, value, isDefault) |
795 | 795 |
{ |
... | ... | |
806 | 806 |
|
807 | 807 |
|
808 | 808 |
/** |
809 |
* @description Accessor that sets the HTTP headers for each transaction.
|
|
810 |
* @method setHeader
|
|
811 |
* @private
|
|
812 |
* @static
|
|
813 |
* @param {object} o The connection object for the transaction.
|
|
814 |
* @return {void}
|
|
809 |
* @description Accessor that sets the HTTP headers for each transaction. |
|
810 |
* @method setHeader |
|
811 |
* @private |
|
812 |
* @static |
|
813 |
* @param {object} o The connection object for the transaction. |
|
814 |
* @return {void} |
|
815 | 815 |
*/ |
816 | 816 |
setHeader:function(o) |
817 | 817 |
{ |
... | ... | |
839 | 839 |
}, |
840 | 840 |
|
841 | 841 |
/** |
842 |
* @description Resets the default HTTP headers object
|
|
843 |
* @method resetDefaultHeaders
|
|
844 |
* @public
|
|
845 |
* @static
|
|
846 |
* @return {void}
|
|
842 |
* @description Resets the default HTTP headers object |
|
843 |
* @method resetDefaultHeaders |
|
844 |
* @public |
|
845 |
* @static |
|
846 |
* @return {void} |
|
847 | 847 |
*/ |
848 | 848 |
resetDefaultHeaders:function(){ |
849 | 849 |
this._default_headers = {}; |
... | ... | |
851 | 851 |
}, |
852 | 852 |
|
853 | 853 |
/** |
854 |
* @description Method to terminate a transaction, if it has not reached readyState 4.
|
|
855 |
* @method abort
|
|
856 |
* @public
|
|
857 |
* @static
|
|
858 |
* @param {object} o The connection object returned by asyncRequest.
|
|
859 |
* @param {object} callback User-defined callback object.
|
|
860 |
* @param {string} isTimeout boolean to indicate if abort resulted from a callback timeout.
|
|
861 |
* @return {boolean}
|
|
854 |
* @description Method to terminate a transaction, if it has not reached readyState 4. |
|
855 |
* @method abort |
|
856 |
* @public |
|
857 |
* @static |
|
858 |
* @param {object} o The connection object returned by asyncRequest. |
|
859 |
* @param {object} callback User-defined callback object. |
|
860 |
* @param {string} isTimeout boolean to indicate if abort resulted from a callback timeout. |
|
861 |
* @return {boolean} |
|
862 | 862 |
*/ |
863 | 863 |
abort:function(o, callback, isTimeout) |
864 | 864 |
{ |
... | ... | |
929 | 929 |
}, |
930 | 930 |
|
931 | 931 |
/** |
932 |
* @description Determines if the transaction is still being processed.
|
|
933 |
* @method isCallInProgress
|
|
934 |
* @public
|
|
935 |
* @static
|
|
936 |
* @param {object} o The connection object returned by asyncRequest
|
|
937 |
* @return {boolean}
|
|
932 |
* @description Determines if the transaction is still being processed. |
|
933 |
* @method isCallInProgress |
|
934 |
* @public |
|
935 |
* @static |
|
936 |
* @param {object} o The connection object returned by asyncRequest |
|
937 |
* @return {boolean} |
|
938 | 938 |
*/ |
939 | 939 |
isCallInProgress:function(o) |
940 | 940 |
{ |
... | ... | |
956 | 956 |
}, |
957 | 957 |
|
958 | 958 |
/** |
959 |
* @description Dereference the XHR instance and the connection object after the transaction is completed.
|
|
960 |
* @method releaseObject
|
|
961 |
* @private
|
|
962 |
* @static
|
|
963 |
* @param {object} o The connection object
|
|
964 |
* @return {void}
|
|
959 |
* @description Dereference the XHR instance and the connection object after the transaction is completed. |
|
960 |
* @method releaseObject |
|
961 |
* @private |
|
962 |
* @static |
|
963 |
* @param {object} o The connection object |
|
964 |
* @return {void} |
|
965 | 965 |
*/ |
966 | 966 |
releaseObject:function(o) |
967 | 967 |
{ |
... | ... | |
978 | 978 |
}; |
979 | 979 |
|
980 | 980 |
/** |
981 |
* @for Connect
|
|
981 |
* @for Connect |
|
982 | 982 |
*/ |
983 | 983 |
(function() { |
984 | 984 |
var YCM = YAHOO.util.Connect, _fn = {}; |
985 | 985 |
|
986 | 986 |
/** |
987 |
* @description This method creates and instantiates the Flash transport.
|
|
988 |
* @method _swf
|
|
989 |
* @private
|
|
990 |
* @static
|
|
991 |
* @param {string} URI to connection.swf.
|
|
992 |
* @return {void}
|
|
987 |
* @description This method creates and instantiates the Flash transport. |
|
988 |
* @method _swf |
|
989 |
* @private |
|
990 |
* @static |
|
991 |
* @param {string} URI to connection.swf. |
|
992 |
* @return {void} |
|
993 | 993 |
*/ |
994 | 994 |
function _swf(uri) { |
995 | 995 |
var o = '<object id="YUIConnectionSwf" type="application/x-shockwave-flash" data="' + |
... | ... | |
1004 | 1004 |
} |
1005 | 1005 |
|
1006 | 1006 |
/** |
1007 |
* @description This method calls the public method on the
|
|
1007 |
* @description This method calls the public method on the |
|
1008 | 1008 |
* Flash transport to start the XDR transaction. It is analogous |
1009 | 1009 |
* to Connection Manager's asyncRequest method. |
1010 |
* @method xdr
|
|
1011 |
* @private
|
|
1012 |
* @static
|
|
1013 |
* @param {object} The transaction object.
|
|
1014 |
* @param {string} HTTP request method.
|
|
1015 |
* @param {string} URI for the transaction.
|
|
1016 |
* @param {object} The transaction's callback object.
|
|
1017 |
* @param {object} The JSON object used as HTTP POST data.
|
|
1018 |
* @return {void}
|
|
1010 |
* @method xdr |
|
1011 |
* @private |
|
1012 |
* @static |
|
1013 |
* @param {object} The transaction object. |
|
1014 |
* @param {string} HTTP request method. |
|
1015 |
* @param {string} URI for the transaction. |
|
1016 |
* @param {object} The transaction's callback object. |
|
1017 |
* @param {object} The JSON object used as HTTP POST data. |
|
1018 |
* @return {void} |
|
1019 | 1019 |
*/ |
1020 | 1020 |
function _xdr(o, m, u, c, d) { |
1021 | 1021 |
_fn[parseInt(o.tId)] = { 'o':o, 'c':c }; |
... | ... | |
1028 | 1028 |
} |
1029 | 1029 |
|
1030 | 1030 |
/** |
1031 |
* @description This method instantiates the Flash transport and
|
|
1031 |
* @description This method instantiates the Flash transport and |
|
1032 | 1032 |
* establishes a static reference to it, used for all XDR requests. |
1033 |
* @method transport
|
|
1034 |
* @public
|
|
1035 |
* @static
|
|
1036 |
* @param {string} URI to connection.swf.
|
|
1037 |
* @return {void}
|
|
1033 |
* @method transport |
|
1034 |
* @public |
|
1035 |
* @static |
|
1036 |
* @param {string} URI to connection.swf. |
|
1037 |
* @return {void} |
|
1038 | 1038 |
*/ |
1039 | 1039 |
function _init(uri) { |
1040 | 1040 |
_swf(uri); |
... | ... | |
1046 | 1046 |
} |
1047 | 1047 |
|
1048 | 1048 |
/** |
1049 |
* @description This method fires the global and transaction start
|
|
1049 |
* @description This method fires the global and transaction start |
|
1050 | 1050 |
* events. |
1051 |
* @method _xdrStart
|
|
1052 |
* @private
|
|
1053 |
* @static
|
|
1054 |
* @param {object} The transaction object.
|
|
1055 |
* @param {string} The transaction's callback object.
|
|
1056 |
* @return {void}
|
|
1051 |
* @method _xdrStart |
|
1052 |
* @private |
|
1053 |
* @static |
|
1054 |
* @param {object} The transaction object. |
|
1055 |
* @param {string} The transaction's callback object. |
|
1056 |
* @return {void} |
|
1057 | 1057 |
*/ |
1058 | 1058 |
function _xdrStart(o, cb) { |
1059 | 1059 |
if (o) { |
... | ... | |
1068 | 1068 |
} |
1069 | 1069 |
|
1070 | 1070 |
/** |
1071 |
* @description This method is the initial response handler
|
|
1071 |
* @description This method is the initial response handler |
|
1072 | 1072 |
* for XDR transactions. The Flash transport calls this |
1073 | 1073 |
* function and sends the response payload. |
1074 |
* @method handleXdrResponse
|
|
1075 |
* @private
|
|
1076 |
* @static
|
|
1077 |
* @param {object} The response object sent from the Flash transport.
|
|
1078 |
* @return {void}
|
|
1074 |
* @method handleXdrResponse |
|
1075 |
* @private |
|
1076 |
* @static |
|
1077 |
* @param {object} The response object sent from the Flash transport. |
|
1078 |
* @return {void} |
|
1079 | 1079 |
*/ |
1080 | 1080 |
function _handleXdrResponse(r) { |
1081 | 1081 |
var o = _fn[r.tId].o, |
... | ... | |
1106 | 1106 |
})(); |
1107 | 1107 |
|
1108 | 1108 |
/** |
1109 |
* @for Connect
|
|
1109 |
* @for Connect |
|
1110 | 1110 |
*/ |
1111 | 1111 |
(function(){ |
1112 | 1112 |
var YCM = YAHOO.util.Connect, |
... | ... | |
1162 | 1162 |
YCM._submitElementValue = null; |
1163 | 1163 |
|
1164 | 1164 |
/** |
1165 |
* @description Custom event that fires when handleTransactionResponse() determines a
|
|
1165 |
* @description Custom event that fires when handleTransactionResponse() determines a |
|
1166 | 1166 |
* response in the HTTP 4xx/5xx range. |
1167 |
* @property failureEvent
|
|
1168 |
* @private
|
|
1169 |
* @static
|
|
1170 |
* @type CustomEvent
|
|
1167 |
* @property failureEvent |
|
1168 |
* @private |
|
1169 |
* @static |
|
1170 |
* @type CustomEvent |
|
1171 | 1171 |
*/ |
1172 | 1172 |
YCM.uploadEvent = new YAHOO.util.CustomEvent('upload'), |
1173 | 1173 |
|
... | ... | |
1199 | 1199 |
}(); |
1200 | 1200 |
|
1201 | 1201 |
/** |
1202 |
* @description This method assembles the form label and value pairs and
|
|
1202 |
* @description This method assembles the form label and value pairs and |
|
1203 | 1203 |
* constructs an encoded string. |
1204 | 1204 |
* asyncRequest() will automatically initialize the transaction with a |
1205 | 1205 |
* a HTTP header Content-Type of application/x-www-form-urlencoded. |
1206 |
* @method setForm
|
|
1207 |
* @public
|
|
1208 |
* @static
|
|
1209 |
* @param {string || object} form id or name attribute, or form object.
|
|
1210 |
* @param {boolean} optional enable file upload.
|
|
1211 |
* @param {boolean} optional enable file upload over SSL in IE only.
|
|
1212 |
* @return {string} string of the HTML form field name and value pairs..
|
|
1206 |
* @method setForm |
|
1207 |
* @public |
|
1208 |
* @static |
|
1209 |
* @param {string || object} form id or name attribute, or form object. |
|
1210 |
* @param {boolean} optional enable file upload. |
|
1211 |
* @param {boolean} optional enable file upload over SSL in IE only. |
|
1212 |
* @return {string} string of the HTML form field name and value pairs.. |
|
1213 | 1213 |
*/ |
1214 | 1214 |
function _setForm(formId, isUpload, secureUri) |
1215 | 1215 |
{ |
... | ... | |
1331 | 1331 |
} |
1332 | 1332 |
|
1333 | 1333 |
/** |
1334 |
* @description Resets HTML form properties when an HTML form or HTML form
|
|
1334 |
* @description Resets HTML form properties when an HTML form or HTML form |
|
1335 | 1335 |
* with file upload transaction is sent. |
1336 |
* @method resetFormState
|
|
1337 |
* @private
|
|
1338 |
* @static
|
|
1339 |
* @return {void}
|
|
1336 |
* @method resetFormState |
|
1337 |
* @private |
|
1338 |
* @static |
|
1339 |
* @return {void} |
|
1340 | 1340 |
*/ |
1341 | 1341 |
function _resetFormState(){ |
1342 | 1342 |
this._isFormSubmit = false; |
... | ... | |
1347 | 1347 |
|
1348 | 1348 |
|
1349 | 1349 |
/** |
1350 |
* @description Creates an iframe to be used for form file uploads. It is remove from the
|
|
1350 |
* @description Creates an iframe to be used for form file uploads. It is remove from the |
|
1351 | 1351 |
* document upon completion of the upload transaction. |
1352 |
* @method createFrame
|
|
1353 |
* @private
|
|
1354 |
* @static
|
|
1355 |
* @param {string} optional qualified path of iframe resource for SSL in IE.
|
|
1356 |
* @return {void}
|
|
1352 |
* @method createFrame |
|
1353 |
* @private |
|
1354 |
* @static |
|
1355 |
* @param {string} optional qualified path of iframe resource for SSL in IE. |
|
1356 |
* @return {void} |
|
1357 | 1357 |
*/ |
1358 | 1358 |
function _createFrame(secureUri){ |
1359 | 1359 |
|
... | ... | |
1386 | 1386 |
} |
1387 | 1387 |
|
1388 | 1388 |
/** |
1389 |
* @description Parses the POST data and creates hidden form elements
|
|
1389 |
* @description Parses the POST data and creates hidden form elements |
|
1390 | 1390 |
* for each key-value, and appends them to the HTML form object. |
1391 |
* @method appendPostData
|
|
1392 |
* @private
|
|
1393 |
* @static
|
|
1394 |
* @param {string} postData The HTTP POST data
|
|
1395 |
* @return {array} formElements Collection of hidden fields.
|
|
1391 |
* @method appendPostData |
|
1392 |
* @private |
|
1393 |
* @static |
|
1394 |
* @param {string} postData The HTTP POST data |
|
1395 |
* @return {array} formElements Collection of hidden fields. |
|
1396 | 1396 |
*/ |
1397 | 1397 |
function _appendPostData(postData){ |
1398 | 1398 |
var formElements = [], |
... | ... | |
1414 | 1414 |
} |
1415 | 1415 |
|
1416 | 1416 |
/** |
1417 |
* @description Uploads HTML form, inclusive of files/attachments, using the
|
|
1417 |
* @description Uploads HTML form, inclusive of files/attachments, using the |
|
1418 | 1418 |
* iframe created in createFrame to facilitate the transaction. |
1419 |
* @method uploadFile
|
|
1420 |
* @private
|
|
1421 |
* @static
|
|
1422 |
* @param {int} id The transaction id.
|
|
1423 |
* @param {object} callback User-defined callback object.
|
|
1424 |
* @param {string} uri Fully qualified path of resource.
|
|
1425 |
* @param {string} postData POST data to be submitted in addition to HTML form.
|
|
1426 |
* @return {void}
|
|
1419 |
* @method uploadFile |
|
1420 |
* @private |
|
1421 |
* @static |
|
1422 |
* @param {int} id The transaction id. |
|
1423 |
* @param {object} callback User-defined callback object. |
|
1424 |
* @param {string} uri Fully qualified path of resource. |
|
1425 |
* @param {string} postData POST data to be submitted in addition to HTML form. |
|
1426 |
* @return {void} |
|
1427 | 1427 |
*/ |
1428 | 1428 |
function _uploadFile(o, callback, uri, postData){ |
1429 | 1429 |
// Each iframe has an id prefix of "yuiIO" followed |
Also available in: Unified diff
fixed headerinfos