replaced tabs with whitespaces
This commit is contained in:
parent
cc9d57d4a4
commit
0f467e616b
1 changed files with 8 additions and 8 deletions
|
@ -38,11 +38,11 @@ The following example illustrates how to use http.request to make a request to a
|
||||||
|
|
||||||
var http = require('./http/request');
|
var http = require('./http/request');
|
||||||
http.request(
|
http.request(
|
||||||
{
|
{
|
||||||
url: 'http://pixenate.com/pixenate/pxn8.pl',
|
url: 'http://pixenate.com/pixenate/pxn8.pl',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
params: {script: '[]'}
|
params: {script: '[]'}
|
||||||
},
|
},
|
||||||
function( responseCode, responseBody ) {
|
function( responseCode, responseBody ) {
|
||||||
var jsObj = eval('(' + responseBody + ')');
|
var jsObj = eval('(' + responseBody + ')');
|
||||||
});
|
});
|
||||||
|
@ -63,7 +63,7 @@ exports.request = function( request, callback ) {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
server.scheduler.runTaskAsynchronously( __plugin, function() {
|
server.scheduler.runTaskAsynchronously( __plugin, function() {
|
||||||
var url, paramsAsString, conn, requestMethod;
|
var url, paramsAsString, conn, requestMethod;
|
||||||
if (typeof request === 'string'){
|
if (typeof request === 'string'){
|
||||||
|
@ -73,13 +73,13 @@ exports.request = function( request, callback ) {
|
||||||
url = request.url;
|
url = request.url;
|
||||||
paramsAsString = paramsToString( request.params );
|
paramsAsString = paramsToString( request.params );
|
||||||
if ( request.method ) {
|
if ( request.method ) {
|
||||||
requestMethod = request.method;
|
requestMethod = request.method;
|
||||||
} else {
|
} else {
|
||||||
requestMethod = 'GET';
|
requestMethod = 'GET';
|
||||||
}
|
}
|
||||||
if ( requestMethod == 'GET' && request.params ) {
|
if ( requestMethod == 'GET' && request.params ) {
|
||||||
// append each parameter to the URL
|
// append each parameter to the URL
|
||||||
url = request.url + '?' + paramsAsString;
|
url = request.url + '?' + paramsAsString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conn = new java.net.URL( url ).openConnection();
|
conn = new java.net.URL( url ).openConnection();
|
||||||
|
@ -90,7 +90,7 @@ exports.request = function( request, callback ) {
|
||||||
if ( conn.requestMethod == 'POST' ) {
|
if ( conn.requestMethod == 'POST' ) {
|
||||||
conn.doInput = true;
|
conn.doInput = true;
|
||||||
// put each parameter in the outputstream
|
// put each parameter in the outputstream
|
||||||
conn.setRequestProperty('Content-Type', 'application/x-www-form-urlencoded');
|
conn.setRequestProperty('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
conn.setRequestProperty('charset', 'utf-8');
|
conn.setRequestProperty('charset', 'utf-8');
|
||||||
conn.setRequestProperty('Content-Length', '' + paramsAsString.length);
|
conn.setRequestProperty('Content-Length', '' + paramsAsString.length);
|
||||||
conn.useCaches =false ;
|
conn.useCaches =false ;
|
||||||
|
|
Reference in a new issue