All Downloads are FREE. Search and download functionalities are using the official Maven repository.

yoke.test.YokeTester.js Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
function YokeTester(yoke, ssl) {
    this.jYokeTester = new com.jetdrone.vertx.yoke.test.YokeTester(yoke.jYoke, ssl || false);
}

YokeTester.prototype.request = function(method, url, headers, body, callback) {
    // 3 args
    if (body === undefined && callback === undefined) {
        this.jYokeTester.request(method, url, new org.vertx.java.core.Handler({
            handle: headers
        }));
    }
    // 4 args
    else if (callback === undefined) {
        this.jYokeTester.request(method, url, toMultiMap(headers), new org.vertx.java.core.Handler({
            handle: body
        }));
    }
    // 5 args
    else {
        this.jYokeTester.request(method, url, toMultiMap(headers), new org.vertx.java.core.buffer.Buffer(body), new org.vertx.java.core.Handler({
            handle: callback
        }));
    }
};

function toMultiMap(json) {
    var headers = new org.vertx.java.core.http.CaseInsensitiveMultiMap();
    for (var k in json) {
        if (json.hasOwnProperty(k)) {
            headers.add(k, json[k]);
        }
    }
    return headers;
}

module.exports = YokeTester;




© 2015 - 2024 Weber Informatics LLC | Privacy Policy