src/net/sec.js
function json(url, method, data, contentType, callback) {
		var requestUrl = url;
		// We might be passed to queue, and then our callback will be the last argument (but possibly not #5
		// if the original call to queue didn't pass all arguments) so we check for that at the start and
		// adjust what we consider the method, data, and contentType parameter values.
		if ( arguments.length > 0 ) {
			if ( arguments.length < 5 && typeof arguments[arguments.length - 1] === 'function' ) {
				callback = arguments[arguments.length - 1];
			}
			if ( typeof method !== 'string' ) {
				method = undefined;
			}
			if ( typeof data !== 'string' ) {
				data = undefined;
			}
			if ( typeof contentType !== 'string' ) {
				contentType = undefined;
			}
		}
		method = (method === undefined ? 'GET' : method.toUpperCase());
		if ( method === 'POST' || method === 'PUT' ) {
			// extract any URL request parameters and put into POST body
			if ( !data ) {
				(function() {
					var queryIndex = url.indexOf('?');
					if ( queryIndex !== -1 ) {
						if ( queryIndex + 1 < url.length - 1 ) {
							data = url.substring(queryIndex + 1);
						}
						requestUrl = url.substring(0, queryIndex);
						contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
					}
				}());
			}
		}
		var xhr = d3.json(requestUrl);
		if ( contentType !== undefined ) {
			xhr.header('Content-Type', contentType);
		}
		xhr.on('beforesend', function(request) {
			var authorization = computeAuthorization(url, method, data, contentType, new Date());

			// set the headers on our request
			request.setRequestHeader('Authorization', authorization.header);
			if ( authorization.bodyContentDigest && shouldIncludeContentDigest(contentType) ) {
				request.setRequestHeader('Digest', authorization.canonicalHeaders.headers['digest']);
			}
			request.setRequestHeader('X-SN-Date', authorization.canonicalHeaders.headers['x-sn-date']);
		});

		// register a load handler always, just so one is present
		xhr.on('load.internal', function() {
			//sn.log('URL {0} response received.', url);
		});

		if ( callback !== undefined ) {
			xhr.send(method, data, callback);
		}
		return xhr;
	}
function json(url, method, data, contentType, callback) {
		var requestUrl = url;
		// We might be passed to queue, and then our callback will be the last argument (but possibly not #5
		// if the original call to queue didn't pass all arguments) so we check for that at the start and
		// adjust what we consider the method, data, and contentType parameter values.
		if ( arguments.length > 0 ) {
			if ( arguments.length < 5 && typeof arguments[arguments.length - 1] === 'function' ) {
				callback = arguments[arguments.length - 1];
			}
			if ( typeof method !== 'string' ) {
				method = undefined;
			}
			if ( typeof data !== 'string' ) {
				data = undefined;
			}
			if ( typeof contentType !== 'string' ) {
				contentType = undefined;
			}
		}
		method = (method === undefined ? 'GET' : method.toUpperCase());
		if ( method === 'POST' || method === 'PUT' ) {
			// extract any URL request parameters and put into POST body
			if ( !data ) {
				(function() {
					var queryIndex = url.indexOf('?');
					if ( queryIndex !== -1 ) {
						if ( queryIndex + 1 < url.length - 1 ) {
							data = url.substring(queryIndex + 1);
						}
						requestUrl = url.substring(0, queryIndex);
						contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
					}
				}());
			}
		}
		var xhr = d3.json(requestUrl);
		if ( contentType !== undefined ) {
			xhr.header('Content-Type', contentType);
		}
		xhr.on('beforesend', function(request) {
			var authorization = computeAuthorization(url, method, data, contentType, new Date());

			// set the headers on our request
			request.setRequestHeader('Authorization', authorization.header);
			if ( authorization.bodyContentDigest && shouldIncludeContentDigest(contentType) ) {
				request.setRequestHeader('Digest', authorization.canonicalHeaders.headers['digest']);
			}
			request.setRequestHeader('X-SN-Date', authorization.canonicalHeaders.headers['x-sn-date']);
		});

		// register a load handler always, just so one is present
		xhr.on('load.internal', function() {
			//sn.log('URL {0} response received.', url);
		});

		if ( callback !== undefined ) {
			xhr.send(method, data, callback);
		}
		return xhr;
	}
function json ( url , method , data , contentType , callback ) { var requestUrl = url ; // We might be passed to queue, and then our callback will be the last argument (but possibly not #5 // if the original call to queue didn't pass all arguments) so we check for that at the start and // adjust what we consider the method, data, and contentType parameter values. if ( arguments . length > 0 ) { if ( arguments . length < 5 && typeof arguments [ arguments . length - 1 ] === 'function' ) { callback = arguments [ arguments . length - 1 ] ; } if ( typeof method !== 'string' ) { method = undefined ; } if ( typeof data !== 'string' ) { data = undefined ; } if ( typeof contentType !== 'string' ) { contentType = undefined ; } } method = ( method === undefined ? 'GET' : method . toUpperCase ( ) ) ; if ( method === 'POST' || method === 'PUT' ) { // extract any URL request parameters and put into POST body if ( ! data ) { ( function ( ) { var queryIndex = url . indexOf ( '?' ) ; if ( queryIndex !== - 1 ) { if ( queryIndex + 1 < url . length - 1 ) { data = url . substring ( queryIndex + 1 ) ; } requestUrl = url . substring ( 0 , queryIndex ) ; contentType = 'application/x-www-form-urlencoded; charset=UTF-8' ; } } ( ) ) ; } } var xhr = d3 . json ( requestUrl ) ; if ( contentType !== undefined ) { xhr . header ( 'Content-Type' , contentType ) ; } xhr . on ( 'beforesend' , function ( request ) { var authorization = computeAuthorization ( url , method , data , contentType , new Date ( ) ) ; // set the headers on our request request . setRequestHeader ( 'Authorization' , authorization . header ) ; if ( authorization . bodyContentDigest && shouldIncludeContentDigest ( contentType ) ) { request . setRequestHeader ( 'Digest' , authorization . canonicalHeaders . headers [ 'digest' ] ) ; } request . setRequestHeader ( 'X-SN-Date' , authorization . canonicalHeaders . headers [ 'x-sn-date' ] ) ; } ) ; // register a load handler always, just so one is present xhr . on ( 'load.internal' , function ( ) { //sn.log('URL {0} response received.', url); } ) ; if ( callback !== undefined ) { xhr . send ( method , data , callback ) ; } return xhr ; }
Invoke the web service URL, adding the required SNWS2 authorization headers to the request.

<p>This method will construct the <code>X-SN-Date</code> and <code>Authorization</code>
header values needed to invoke the web service. It returns a d3 XHR object,
so you can call <code>.on()</code> on that to handle the response, unless a callback
parameter is specified, then the request is issued immediately, passing the
<code>method</code>, <code>data</code>, and <code>callback</code> parameters
to <code>xhr.send()</code>.</p>

@param {String} url the web service URL to invoke
@param {String} method the HTTP method to use; e.g. GET or POST
@param {String} [data] the data to upload
@param {String} [contentType] the content type of the data
@param {Function} [callback] if defined, a d3 callback function to handle the response JSON with
@return {Object} d3 XHR object
@preserve
Invoke the web service URL adding the required SNWS2 authorization headers to the request .