nl_tokens: Initializes the xhr - instance based on the config - params . This method is the standard way of doing xhr - requests without processing streams .
pl_tokens: function ( xhr , options , promise ) { var instance = this , url = options . url , method = options . method || GET , headers = options . headers ? options . headers . itsa_deepClone ( ) : { } , // all request will get some headers async = ! options . sync , data = options . data , reject = promise . reject , sendPayload , additionalData ; // xhr will be null in case of a CORS-request when no CORS is possible if ( ! xhr ) { console . error ( NAME , "_initXHR fails: " + ERROR_NO_XHR ) ; reject ( ERROR_NO_XHR ) ; return ; } // adding default headers (when set): headers . itsa_merge ( instance . _standardHeaders ) ; // method-name should be in uppercase: method = method . toUpperCase ( ) ; // in case of BODY-method: eliminate any data behind querystring: // else: append data-object behind querystring if ( BODY_METHODS [ method ] ) { url = url . split ( "?" ) ; // now url is an array url [ 1 ] && ( additionalData = instance . _queryStringToDataObject ( url [ 1 ] ) ) ; if ( additionalData && ! additionalData . itsa_isEmpty ( ) ) { data || ( data = { } ) ; <mask> . itsa_merge ( additionalData ) ; } url = url [ 0 ] ; // now url is a String again } else if ( data && ( headers [ CONTENT_TYPE ] !== MIME_BLOB ) ) { url += ( url . itsa_contains ( "?" ) ? "&" : "?" ) + instance . _toQueryString ( data ) ; } xhr . open ( method , url , async ) ; options . responseType && ( xhr . responseType = options . responseType ) ; options . withCredentials && ( xhr . withCredentials = true ) ; // more initialisation might be needed by extended modules: instance . _xhrInitList . forEach ( function ( fn ) { fn ( xhr , promise , headers , method ) ; } ) ; if ( BODY_METHODS [ method ] && data ) { if ( headers [ CONTENT_TYPE ] === MIME_BLOB ) { if ( ! xhr . _isXDR ) { sendPayload = data ; } } else { sendPayload = ( ( headers [ CONTENT_TYPE ] === MIME_JSON ) || xhr . _isXDR ) ? JSON . stringify ( data ) : instance . _toQueryString ( data ) ; } } // send the request: xhr . send ( sendPayload ) ; // now add xhr.abort() to the promise, so we can call from within the returned promise-instance promise . abort = function ( ) { reject ( ABORTED ) ; xhr . _aborted = true ; // must be set: IE9 won"t allow to read anything on xhr after being aborted xhr . abort ( ) ; } ; // in case synchronous transfer: force an xhr.onreadystatechange: async || xhr . onreadystatechange ( ) ; }