mplane_http_transport.js
function showResults(redeem , options , callback){
    if (typeof redeem !== 'object')
            redeem = new mplane.Redemption(redeem);
    var post_data = redeem.to_dict();
    var post_options = {
        path: SUPERVISOR_PATH_SHOW_RESULT,
        method: 'POST',
        host: options.host,
        port: options.port,
        followRedirect:false,
        headers: {
            'Content-Type': MIME_TYPE,
            'Content-Length': Buffer.byteLength(post_data)
        }
    };
    post_options.ca = ssl_files.readCaChain(options.ca);
    post_options.key = ssl_files.readFileContent(options.key);
    post_options.cert = ssl_files.readFileContent(options.cert);
    // Try to redeem the specification
    var post_req = https.request(post_options, function(res) {
        var bodyChunks=[];
        res.on('data', function (chunk) {
            bodyChunks.push(chunk);
        }).on('end', function () {
            body = Buffer.concat(bodyChunks);
            if (res.statusCode != 200){
                if (res.statusCode == 403){
                    callback(new Error(403),null);
                    return;
                }else{
                    callback(new Error("Error from server"),null);//Wrong answer
                    return;
                }
            }
            var result = mplane.from_dict(body);
            callback(null,result);
        });
    });
    post_req.on("error", function(err){
        callback(err,null)
    });
    post_req.write(post_data);
    post_req.end();
}
function showResults(redeem , options , callback){
    if (typeof redeem !== 'object')
            redeem = new mplane.Redemption(redeem);
    var post_data = redeem.to_dict();
    var post_options = {
        path: SUPERVISOR_PATH_SHOW_RESULT,
        method: 'POST',
        host: options.host,
        port: options.port,
        followRedirect:false,
        headers: {
            'Content-Type': MIME_TYPE,
            'Content-Length': Buffer.byteLength(post_data)
        }
    };
    post_options.ca = ssl_files.readCaChain(options.ca);
    post_options.key = ssl_files.readFileContent(options.key);
    post_options.cert = ssl_files.readFileContent(options.cert);
    // Try to redeem the specification
    var post_req = https.request(post_options, function(res) {
        var bodyChunks=[];
        res.on('data', function (chunk) {
            bodyChunks.push(chunk);
        }).on('end', function () {
            body = Buffer.concat(bodyChunks);
            if (res.statusCode != 200){
                if (res.statusCode == 403){
                    callback(new Error(403),null);
                    return;
                }else{
                    callback(new Error("Error from server"),null);//Wrong answer
                    return;
                }
            }
            var result = mplane.from_dict(body);
            callback(null,result);
        });
    });
    post_req.on("error", function(err){
        callback(err,null)
    });
    post_req.write(post_data);
    post_req.end();
}
function showResults ( redeem , options , callback ) { if ( typeof redeem !== 'object' ) redeem = new mplane . Redemption ( redeem ) ; var post_data = redeem . to_dict ( ) ; var post_options = { path : SUPERVISOR_PATH_SHOW_RESULT , method : 'POST' , host : options . host , port : options . port , followRedirect : false , headers : { 'Content-Type' : MIME_TYPE , 'Content-Length' : Buffer . byteLength ( post_data ) } } ; post_options . ca = ssl_files . readCaChain ( options . ca ) ; post_options . key = ssl_files . readFileContent ( options . key ) ; post_options . cert = ssl_files . readFileContent ( options . cert ) ; // Try to redeem the specification var post_req = https . request ( post_options , function ( res ) { var bodyChunks = [ ] ; res . on ( 'data' , function ( chunk ) { bodyChunks . push ( chunk ) ; } ) . on ( 'end' , function ( ) { body = Buffer . concat ( bodyChunks ) ; if ( res . statusCode != 200 ) { if ( res . statusCode == 403 ) { callback ( new Error ( 403 ) , null ) ; return ; } else { callback ( new Error ( "Error from server" ) , null ) ; //Wrong answer return ; } } var result = mplane . from_dict ( body ) ; callback ( null , result ) ; } ) ; } ) ; post_req . on ( "error" , function ( err ) { callback ( err , null ) } ) ; post_req . write ( post_data ) ; post_req . end ( ) ; }
Given a redeem, ask if results are ready
@param redeem
@param options
@param callback
Given a redeem ask if results are ready