src/aria/core/IO.js
function (req) {
            // increment before assigning to avoid setting request id 0 (which does not work well with abort)
            this.nbRequests++;
            req.id = this.nbRequests;

            var reqMethods = ["GET", "POST", "PUT", "DELETE", "HEAD", "TRACE", "OPTIONS", "CONNECT", "PATCH", "COPY",
                    "PROPFIND", "MKCOL", "PROPPATCH", "MOVE", "LOCK", "UNLOCK", "BIND", "UNBIND", "REBIND"];
            // Assign a request timeout in order of importance:
            // # req.timeout - User specified timeout
            // # req.callback.timeout - Timeout of the callback function (might be set by filters)
            // # this.defaultTimeout - Default IO timeout
            if (req.timeout == null) {
                req.timeout = (req.callback == null || req.callback.timeout == null)
                        ? this.defaultTimeout
                        : req.callback.timeout;
            }

            if (!req.method) {
                req.method = "GET";
            } else {
                req.method = req.method.toUpperCase();
            }

            if (!(require("../utils/Array")).contains(reqMethods, req.method)) {
                return this.$logWarn("The request method %1 is invalid", [req.method]);
            }

            var headers = {};
            // First take the default IO headers
            for (var key in this.headers) {
                if (this.headers.hasOwnProperty(key)) {
                    headers[key] = this.headers[key];
                }
            }
            // Then add POST/PUT-specific headers
            if (req.method === "POST" || req.method === "PUT") {
                for (var key in this.postHeaders) {
                    if (this.postHeaders.hasOwnProperty(key)) {
                        headers[key] = this.postHeaders[key];
                    }
                }
            }
            // Then the headers from the request object
            for (var key in req.headers) {
                if (req.headers.hasOwnProperty(key)) {
                    headers[key] = req.headers[key];
                }
            }

            req.headers = headers;
        }
function (req) {
            // increment before assigning to avoid setting request id 0 (which does not work well with abort)
            this.nbRequests++;
            req.id = this.nbRequests;

            var reqMethods = ["GET", "POST", "PUT", "DELETE", "HEAD", "TRACE", "OPTIONS", "CONNECT", "PATCH", "COPY",
                    "PROPFIND", "MKCOL", "PROPPATCH", "MOVE", "LOCK", "UNLOCK", "BIND", "UNBIND", "REBIND"];
            // Assign a request timeout in order of importance:
            // # req.timeout - User specified timeout
            // # req.callback.timeout - Timeout of the callback function (might be set by filters)
            // # this.defaultTimeout - Default IO timeout
            if (req.timeout == null) {
                req.timeout = (req.callback == null || req.callback.timeout == null)
                        ? this.defaultTimeout
                        : req.callback.timeout;
            }

            if (!req.method) {
                req.method = "GET";
            } else {
                req.method = req.method.toUpperCase();
            }

            if (!(require("../utils/Array")).contains(reqMethods, req.method)) {
                return this.$logWarn("The request method %1 is invalid", [req.method]);
            }

            var headers = {};
            // First take the default IO headers
            for (var key in this.headers) {
                if (this.headers.hasOwnProperty(key)) {
                    headers[key] = this.headers[key];
                }
            }
            // Then add POST/PUT-specific headers
            if (req.method === "POST" || req.method === "PUT") {
                for (var key in this.postHeaders) {
                    if (this.postHeaders.hasOwnProperty(key)) {
                        headers[key] = this.postHeaders[key];
                    }
                }
            }
            // Then the headers from the request object
            for (var key in req.headers) {
                if (req.headers.hasOwnProperty(key)) {
                    headers[key] = req.headers[key];
                }
            }

            req.headers = headers;
        }
function ( req ) { // increment before assigning to avoid setting request id 0 (which does not work well with abort) this . nbRequests ++ ; req . id = this . nbRequests ; var reqMethods = [ "GET" , "POST" , "PUT" , "DELETE" , "HEAD" , "TRACE" , "OPTIONS" , "CONNECT" , "PATCH" , "COPY" , "PROPFIND" , "MKCOL" , "PROPPATCH" , "MOVE" , "LOCK" , "UNLOCK" , "BIND" , "UNBIND" , "REBIND" ] ; // Assign a request timeout in order of importance: // # req.timeout - User specified timeout // # req.callback.timeout - Timeout of the callback function (might be set by filters) // # this.defaultTimeout - Default IO timeout if ( req . timeout == null ) { req . timeout = ( req . callback == null || req . callback . timeout == null ) ? this . defaultTimeout : req . callback . timeout ; } if ( ! req . method ) { req . method = "GET" ; } else { req . method = req . method . toUpperCase ( ) ; } if ( ! ( require ( "../utils/Array" ) ) . contains ( reqMethods , req . method ) ) { return this . $logWarn ( "The request method %1 is invalid" , [ req . method ] ) ; } var headers = { } ; // First take the default IO headers for ( var key in this . headers ) { if ( this . headers . hasOwnProperty ( key ) ) { headers [ key ] = this . headers [ key ] ; } } // Then add POST/PUT-specific headers if ( req . method === "POST" || req . method === "PUT" ) { for ( var key in this . postHeaders ) { if ( this . postHeaders . hasOwnProperty ( key ) ) { headers [ key ] = this . postHeaders [ key ] ; } } } // Then the headers from the request object for ( var key in req . headers ) { if ( req . headers . hasOwnProperty ( key ) ) { headers [ key ] = req . headers [ key ] ; } } req . headers = headers ; }
Normalize the Request object adding default values and additional parameters like a unique ID
@param {aria.core.CfgBeans:IOAsyncRequestCfg} req Request object as the input parameter of asyncRequest
@private
Normalize the Request object adding default values and additional parameters like a unique ID