lib/multi-data.js
function postData(fields, files, options, headers, callback) {
    var headerparams = getFormDataForPost(fields, files);
    var totalheaders = headerparams.headers;
    for (var key in headers) totalheaders[key] = headers[key];

    var post_options = {
        host: options.host,
        port: options.port,
        path: options.path,
        method: options.method || 'POST',
        headers: totalheaders
    };
    var request = Http.request(post_options, function(response) {
        response.body = '';
        response.setEncoding(options.encoding);
        response.on('data', function(chunk) {
            console.log(chunk);
            response.body += chunk;
        });
        response.on('end', function() {
            callback(null, response)
        });
    });

    for (var i = 0; i < headerparams.postdata.length; i++) {
        request.write(headerparams.postdata[i]);
    }

    request.end();
}
function postData(fields, files, options, headers, callback) {
    var headerparams = getFormDataForPost(fields, files);
    var totalheaders = headerparams.headers;
    for (var key in headers) totalheaders[key] = headers[key];

    var post_options = {
        host: options.host,
        port: options.port,
        path: options.path,
        method: options.method || 'POST',
        headers: totalheaders
    };
    var request = Http.request(post_options, function(response) {
        response.body = '';
        response.setEncoding(options.encoding);
        response.on('data', function(chunk) {
            console.log(chunk);
            response.body += chunk;
        });
        response.on('end', function() {
            callback(null, response)
        });
    });

    for (var i = 0; i < headerparams.postdata.length; i++) {
        request.write(headerparams.postdata[i]);
    }

    request.end();
}
function postData ( fields , files , options , headers , callback ) { var headerparams = getFormDataForPost ( fields , files ) ; var totalheaders = headerparams . headers ; for ( var key in headers ) totalheaders [ key ] = headers [ key ] ; var post_options = { host : options . host , port : options . port , path : options . path , method : options . method || 'POST' , headers : totalheaders } ; var request = Http . request ( post_options , function ( response ) { response . body = '' ; response . setEncoding ( options . encoding ) ; response . on ( 'data' , function ( chunk ) { console . log ( chunk ) ; response . body += chunk ; } ) ; response . on ( 'end' , function ( ) { callback ( null , response ) } ) ; } ) ; for ( var i = 0 ; i < headerparams . postdata . length ; i ++ ) { request . write ( headerparams . postdata [ i ] ) ; } request . end ( ) ; }
Sends a post form request via http
- `fields` - a property map of key value pairs
- `files` - a list of property maps of content
- `type` - the type of file data
- `keyname` - the name of the key corresponding to the file
- `valuename` - the name of the value corresponding to the file
- `data` - the data of the file
- `options` is a set of options
- host
- port
- path
- method
- encoding
- `headers` headers to be sent with the request
- `callback` - callback to handle the response
Sends a post form request via http - fields - a property map of key value pairs - files - a list of property maps of content - type - the type of file data - keyname - the name of the key corresponding to the file - valuename - the name of the value corresponding to the file - data - the data of the file - options is a set of options - host - port - path - method - encoding - headers headers to be sent with the request - callback - callback to handle the response