lib/http.js
function(url, message, callback) {
            var that = this;
            var wrappedCallback = function(response) {
                callback = callback || function() {};

                // Handle cookies if 'set-cookie' header is in the response

                var cookieHeaders = response.response.headers['set-cookie'];
                if (cookieHeaders) {
                    utils.forEach(cookieHeaders, function (cookieHeader) {
                        var cookie = that._parseCookieHeader(cookieHeader);
                        that._cookieStore[cookie.key] = cookie.value;
                    });
                }

                // Handle callback

                if (response.status < 400 && response.status !== "abort") {
                    callback(null, response);
                }
                else {
                    callback(response);
                }
            };

            var query = utils.getWithVersion(this.version, queryBuilderMap)(message);
            var post = message.post || {};

            var encodedUrl = url + "?" + Http.encode(query);
            var body = message.body ? message.body : Http.encode(post);

            var cookieString = that._getCookieString();

            if (cookieString.length !== 0) {
                message.headers["Cookie"] = cookieString;

                // Remove Authorization header
                // Splunk will use Authorization header and ignore Cookies if Authorization header is sent
                delete message.headers["Authorization"];
            }

            var options = {
                method: message.method,
                headers: message.headers,
                timeout: message.timeout,
                body: body
            };

            // Now we can invoke the user-provided HTTP class,
            // passing in our "wrapped" callback
            return this.makeRequest(encodedUrl, options, wrappedCallback);
        }
function(url, message, callback) {
            var that = this;
            var wrappedCallback = function(response) {
                callback = callback || function() {};

                // Handle cookies if 'set-cookie' header is in the response

                var cookieHeaders = response.response.headers['set-cookie'];
                if (cookieHeaders) {
                    utils.forEach(cookieHeaders, function (cookieHeader) {
                        var cookie = that._parseCookieHeader(cookieHeader);
                        that._cookieStore[cookie.key] = cookie.value;
                    });
                }

                // Handle callback

                if (response.status < 400 && response.status !== "abort") {
                    callback(null, response);
                }
                else {
                    callback(response);
                }
            };

            var query = utils.getWithVersion(this.version, queryBuilderMap)(message);
            var post = message.post || {};

            var encodedUrl = url + "?" + Http.encode(query);
            var body = message.body ? message.body : Http.encode(post);

            var cookieString = that._getCookieString();

            if (cookieString.length !== 0) {
                message.headers["Cookie"] = cookieString;

                // Remove Authorization header
                // Splunk will use Authorization header and ignore Cookies if Authorization header is sent
                delete message.headers["Authorization"];
            }

            var options = {
                method: message.method,
                headers: message.headers,
                timeout: message.timeout,
                body: body
            };

            // Now we can invoke the user-provided HTTP class,
            // passing in our "wrapped" callback
            return this.makeRequest(encodedUrl, options, wrappedCallback);
        }
function ( url , message , callback ) { var that = this ; var wrappedCallback = function ( response ) { callback = callback || function ( ) { } ; // Handle cookies if 'set-cookie' header is in the response var cookieHeaders = response . response . headers [ 'set-cookie' ] ; if ( cookieHeaders ) { utils . forEach ( cookieHeaders , function ( cookieHeader ) { var cookie = that . _parseCookieHeader ( cookieHeader ) ; that . _cookieStore [ cookie . key ] = cookie . value ; } ) ; } // Handle callback if ( response . status < 400 && response . status !== "abort" ) { callback ( null , response ) ; } else { callback ( response ) ; } } ; var query = utils . getWithVersion ( this . version , queryBuilderMap ) ( message ) ; var post = message . post || { } ; var encodedUrl = url + "?" + Http . encode ( query ) ; var body = message . body ? message . body : Http . encode ( post ) ; var cookieString = that . _getCookieString ( ) ; if ( cookieString . length !== 0 ) { message . headers [ "Cookie" ] = cookieString ; // Remove Authorization header // Splunk will use Authorization header and ignore Cookies if Authorization header is sent delete message . headers [ "Authorization" ] ; } var options = { method : message . method , headers : message . headers , timeout : message . timeout , body : body } ; // Now we can invoke the user-provided HTTP class, // passing in our "wrapped" callback return this . makeRequest ( encodedUrl , options , wrappedCallback ) ; }
Performs a request.

This function sets up how to handle a response from a request, but
delegates calling the request to the `makeRequest` subclass.

@param {String} url The encoded URL of the request.
@param {Object} message An object with values for method, headers, timeout, and encoded body.
@param {Function} callback The function to call when the request is complete: `(err, response)`.

@method splunkjs.Http
@see makeRequest
Performs a request .