javascript/lib/extensions/Networking.js
function(config) {
    var hasParams = (typeof config.params === 'object');
    var hasFiles = _.isArray(config.attachments);
    
    if('GET' === config.method) {
        if(hasParams) {
            config.url = addParams(config.url, config.params);
        }
        if (hasFiles) {
            throw new Error("Cannot upload files with a GET request");
        }    
    } else if('POST' === config.method) {
        if(typeof config.postData !== "undefined") {
            // We have raw POST data to send up so we give it no further treatment.
            config.params = config.postData;
        } else if (hasFiles) {
            if (hasParams) {
                config.paramMap = _.clone(config.params);
                _.each(config.paramMap, function (num, key) {
                    var value = config.paramMap[key];
                    if (value === null) {
                        delete config.paramMap[key];
                    }
                });
                
                delete config.params;
                _.each(config.attachments, function (filestats) {
                    api.normalizeAPI({    
                        'string': {
                            mandatory: ['name'],
                            oneOf: ['filename', 'fileArea', 'filePath'],
                            optional: ['contentType', 'name']
                        }
                    }, filestats);
                });
                
            }
        } else if(hasParams) {
            // We have a bunch of key/values, so we need to encode each of them.
            // A string like a posted form is created. e.g. "param1key=param1value&param2key=param2value"
            var paramsWithQuestion = addParams('', config.params);
            config.params = paramsWithQuestion.substring(1); // Lop off the '?' at the head
        }
        

    }
}
function(config) {
    var hasParams = (typeof config.params === 'object');
    var hasFiles = _.isArray(config.attachments);
    
    if('GET' === config.method) {
        if(hasParams) {
            config.url = addParams(config.url, config.params);
        }
        if (hasFiles) {
            throw new Error("Cannot upload files with a GET request");
        }    
    } else if('POST' === config.method) {
        if(typeof config.postData !== "undefined") {
            // We have raw POST data to send up so we give it no further treatment.
            config.params = config.postData;
        } else if (hasFiles) {
            if (hasParams) {
                config.paramMap = _.clone(config.params);
                _.each(config.paramMap, function (num, key) {
                    var value = config.paramMap[key];
                    if (value === null) {
                        delete config.paramMap[key];
                    }
                });
                
                delete config.params;
                _.each(config.attachments, function (filestats) {
                    api.normalizeAPI({    
                        'string': {
                            mandatory: ['name'],
                            oneOf: ['filename', 'fileArea', 'filePath'],
                            optional: ['contentType', 'name']
                        }
                    }, filestats);
                });
                
            }
        } else if(hasParams) {
            // We have a bunch of key/values, so we need to encode each of them.
            // A string like a posted form is created. e.g. "param1key=param1value&param2key=param2value"
            var paramsWithQuestion = addParams('', config.params);
            config.params = paramsWithQuestion.substring(1); // Lop off the '?' at the head
        }
        

    }
}
function ( config ) { var hasParams = ( typeof config . params === 'object' ) ; var hasFiles = _ . isArray ( config . attachments ) ; if ( 'GET' === config . method ) { if ( hasParams ) { config . url = addParams ( config . url , config . params ) ; } if ( hasFiles ) { throw new Error ( "Cannot upload files with a GET request" ) ; } } else if ( 'POST' === config . method ) { if ( typeof config . postData !== "undefined" ) { // We have raw POST data to send up so we give it no further treatment. config . params = config . postData ; } else if ( hasFiles ) { if ( hasParams ) { config . paramMap = _ . clone ( config . params ) ; _ . each ( config . paramMap , function ( num , key ) { var value = config . paramMap [ key ] ; if ( value === null ) { delete config . paramMap [ key ] ; } } ) ; delete config . params ; _ . each ( config . attachments , function ( filestats ) { api . normalizeAPI ( { 'string' : { mandatory : [ 'name' ] , oneOf : [ 'filename' , 'fileArea' , 'filePath' ] , optional : [ 'contentType' , 'name' ] } } , filestats ) ; } ) ; } } else if ( hasParams ) { // We have a bunch of key/values, so we need to encode each of them. // A string like a posted form is created. e.g. "param1key=param1value&param2key=param2value" var paramsWithQuestion = addParams ( '' , config . params ) ; config . params = paramsWithQuestion . substring ( 1 ) ; // Lop off the '?' at the head } } }
If the method is GET, the config.url string will have any parameters in the config.params added to it appropriately.

If the method is POST and there is no config.postData, the config.params object will be changed to a string. The form of this string will be "param1key=param1value&param2key=param2value". Each key and value will be encoded using encodeURIComponent().
If the method is POST and there is a config.postData string, the config.params object will be changed to be the same as the postData string. No encoding will take placed.
If the method is GET the config . url string will have any parameters in the config . params added to it appropriately .