_buildResponse

splunkjs.Http._buildResponse

Generates a unified response with the given parameters.

Syntax

_buildResponse: function(error, response, data)

Parameters

Name Type Description
error Object

An error object, if one exists for the request.

response Object

The response object.

data Object

The response data.

Return

Object.

A unified response object.

del

splunkjs.Http.del

Performs a DELETE request.

Syntax

del: function(url, headers, params, timeout, callback)

Parameters

Name Type Description
url String

The URL of the DELETE request.

headers Object

An object of headers for this request.

params Object

Query parameters for this request.

timeout Number

A timeout period. This parameter is not used.

callback Function

The function to call when the request is complete: (err, response).

get

splunkjs.Http.get

Performs a GET request.

Syntax

get: function(url, headers, params, timeout, callback)

Parameters

Name Type Description
url String

The URL of the GET request.

headers Object

An object of headers for this request.

params Object

Parameters for this request.

timeout Number

A timeout period. This parameter is not used.

callback Function

The function to call when the request is complete: (err, response).

init

splunkjs.Http.init

Constructor for splunkjs.Http.

Syntax

init: function()

Return

splunkjs.Http.

A new splunkjs.Http instance.

makeRequest

splunkjs.Http.makeRequest

Encapsulates the client-specific logic for performing a request. This function is meant to be overriden by subclasses.

Syntax

makeRequest: function(url, message, callback)

Parameters

Name Type Description
url String

The encoded URL of the request.

message Object

An object with values for method, headers, timeout, and encoded body.

callback Function

The function to call when the request is complete: (err, response).

parseJson

splunkjs.Http.parseJson

Encapsulates the client-specific logic for parsing the JSON response.

Syntax

parseJson: function(json)

Parameters

Name Type Description
json String

The JSON response to parse.

Return

Object.

The parsed JSON.

post

splunkjs.Http.post

Performs a POST request.

Syntax

post: function(url, headers, params, timeout, callback)

Parameters

Name Type Description
url String

The URL of the POST request.

headers Object

An object of headers for this request.

params Object

Parameters for this request.

timeout Number

A timeout period. This parameter is not used.

callback Function

The function to call when the request is complete: (err, response).

request

splunkjs.Http.request

Performs a request.

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

Syntax

request: function(url, message, callback)

Parameters

Name Type Description
url String

The encoded URL of the request.

message Object

An object with values for method, headers, timeout, and encoded body.

callback Function

The function to call when the request is complete: (err, response).

encode

splunkjs.Http.encode

Encodes a dictionary of values into a URL-encoded format.

Syntax

Http.encode = function(params)

Parameters

Name Type Description
params Object

The parameters to URL encode.

Return

String.

The URL-encoded string.

Examples

 // should be a=1&b=2&b=3&b=4
 encode({a: 1, b: [2,3,4]})