Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 22 additions & 39 deletions lib/solr.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,8 @@ Client.prototype.update = function(data,options,callback){
.join('/');

var params = {
host : this.options.host,
port : this.options.port,
fullPath : fullPath,
url : (this.options.secure? "https" : "http") + '://' + this.options.host +':' + this.options.port + fullPath,
json : json,
secure : this.options.secure,
bigint : this.options.bigint,
authorization : this.options.authorization,
agent : this.options.agent,
Expand Down Expand Up @@ -649,10 +646,7 @@ Client.prototype.get = function(handler,query,callback){

if (this.options.get_max_request_entity_size === false || approxUrlLength <= this.options.get_max_request_entity_size) {
var params = {
host: this.options.host,
port: this.options.port,
fullPath: fullPath,
secure: this.options.secure,
url : (this.options.secure? "https" : "http") + '://' + this.options.host +':' + this.options.port + fullPath,
bigint: this.options.bigint,
authorization: this.options.authorization,
agent: this.options.agent,
Expand Down Expand Up @@ -704,11 +698,8 @@ Client.prototype.post = function(handler,query,callback){
}).join('/');

var params = {
host : this.options.host,
port : this.options.port,
fullPath : fullPath,
url : (this.options.secure? "https" : "http") + '://' + this.options.host +':' + this.options.port + fullPath,
params : parameters,
secure : this.options.secure,
bigint : this.options.bigint,
authorization : this.options.authorization,
agent : this.options.agent,
Expand Down Expand Up @@ -827,30 +818,27 @@ function postJSON(params,callback){
headers['authorization'] = params.authorization;
}
var options = {
host : params.host,
port : params.port,
method : 'POST',
url: params.url,
headers : headers,
path : params.fullPath,
family : params.ipversion
};

if(params.agent !== undefined){
options.agent = params.agent;
}

var request = pickProtocol(params.secure).request(options);
var postRequest = request.post(options);

request.on('response', handleJSONResponse(request, params.bigint, callback));
postRequest.on('response', handleJSONResponse(postRequest, params.bigint, callback));

request.on('error',function onError(err){
postRequest.on('error',function onError(err){
if (callback) callback(err,null);
});

request.write(params.json);
request.end();
postRequest.write(params.json);
postRequest.end();

return request;
return postRequest;
};

/**
Expand Down Expand Up @@ -884,30 +872,27 @@ function postForm(params,callback){
headers['authorization'] = params.authorization;
}
var options = {
host : params.host,
port : params.port,
method : 'POST',
url: params.url,
headers : headers,
path : params.fullPath,
family : params.ipVersion
};

if(params.agent !== undefined){
options.agent = params.agent;
}

var request = pickProtocol(params.secure).request(options);
var postRequest = request.post(options);

request.on('response', handleJSONResponse(request, params.bigint, callback));
postRequest.on('response', handleJSONResponse(postRequest, params.bigint, callback));

request.on('error',function onError(err){
postRequest.on('error',function onError(err){
if (callback) callback(err,null);
});

request.write(params.params);
request.end();
postRequest.write(params.params);
postRequest.end();

return request;
return postRequest;
};

/**
Expand Down Expand Up @@ -935,9 +920,7 @@ function getJSON(params,callback){
'accept' : 'application/json; charset=utf-8'
};
var options = {
host : params.host,
port : params.port,
path : params.fullPath,
url : params.url,
headers : headers,
family: params.ipVersion
};
Expand All @@ -953,14 +936,14 @@ function getJSON(params,callback){
options.headers = headers;
}

var request = pickProtocol(params.secure).get(options);
var getRequest = request.get(options);

request.on('response', handleJSONResponse(request, params.bigint, callback));
getRequest.on('response', handleJSONResponse(getRequest, params.bigint, callback));

request.on('error',function(err){
getRequest.on('error',function(err){
if (callback) callback(err,null);
});
return request;
return getRequest;
};

/**
Expand Down