本文整理了Java中io.vertx.core.http.HttpClient.requestAbs()
方法的一些代码示例,展示了HttpClient.requestAbs()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.requestAbs()
方法的具体详情如下:
包路径:io.vertx.core.http.HttpClient
类名称:HttpClient
方法名:requestAbs
[英]Create an HTTP request to send to the server using an absolute URI
[中]使用绝对URI创建要发送到服务器的HTTP请求
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testInvalidAbsoluteURI() {
try {
client.requestAbs(HttpMethod.GET, "ijdijwidjqwoijd192d192192ej12d", resp -> {
}).end();
fail("Should throw exception");
} catch (VertxException e) {
//OK
}
}
代码示例来源:origin: eclipse-vertx/vert.x
private void testSimpleRequest(String uri, HttpMethod method, boolean absolute, Handler<HttpClientResponse> handler) {
boolean ssl = this instanceof Http2Test;
HttpClientRequest req;
if (absolute) {
req = client.requestAbs(method, (ssl ? "https://" : "http://") + DEFAULT_HTTP_HOST + ":" + DEFAULT_HTTP_PORT + uri, onSuccess(handler::handle));
} else {
req = client.request(method, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, uri, onSuccess(handler::handle));
}
testSimpleRequest(uri, method, req, absolute);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void requestAbsNoPort() {
client.requestAbs(HttpMethod.GET, "http://www.google.com", res -> testComplete()).end();
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
// Client trusts all server certs
public void testClearClientRequestAbsSetSSL() throws Exception {
String absoluteURI = "https://" + DEFAULT_HTTP_HOST + ":4043/" + DEFAULT_TEST_URI;
testTLS(Cert.NONE, Trust.SERVER_JKS, Cert.SERVER_JKS, Trust.NONE).clientSSL(false).requestProvider((c, handler) -> c.requestAbs(HttpMethod.POST, absoluteURI, handler)).pass();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
// Client trusts all server certs
public void testSSLClientRequestAbsSetSSL() throws Exception {
String absoluteURI = "https://" + DEFAULT_HTTP_HOST + ":4043/" + DEFAULT_TEST_URI;
testTLS(Cert.NONE, Trust.SERVER_JKS, Cert.SERVER_JKS, Trust.NONE).clientSSL(true).requestProvider((c, handler) -> c.requestAbs(HttpMethod.POST, absoluteURI, handler)).pass();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
// Client trusts all server certs
public void testSSLClientRequestAbsSetClear() throws Exception {
String absoluteURI = "http://" + DEFAULT_HTTP_HOST + ":4043/" + DEFAULT_TEST_URI;
testTLS(Cert.NONE, Trust.SERVER_JKS, Cert.SERVER_JKS, Trust.NONE).clientSSL(true).serverSSL(false).requestProvider((c, handler) -> c.requestAbs(HttpMethod.POST, absoluteURI, handler)).pass();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
// Client trusts all server certs
public void testClearClientRequestAbsSetClear() throws Exception {
String absoluteURI = "http://" + DEFAULT_HTTP_HOST + ":4043/" + DEFAULT_TEST_URI;
testTLS(Cert.NONE, Trust.SERVER_JKS, Cert.SERVER_JKS, Trust.NONE).clientSSL(false).serverSSL(false).requestProvider((c, handler) -> c.requestAbs(HttpMethod.POST, absoluteURI, handler)).pass();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testRequestNPE() {
String uri = "/some-uri?foo=bar";
TestUtils.assertNullPointerException(() -> client.request(HttpMethod.GET, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, uri, null));
TestUtils.assertNullPointerException(() -> client.request((HttpMethod)null, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, uri, resp -> {}));
TestUtils.assertNullPointerException(() -> client.requestAbs((HttpMethod) null, "http://someuri", resp -> {
}));
TestUtils.assertNullPointerException(() -> client.request(HttpMethod.GET, 8080, "localhost", "/somepath", null));
TestUtils.assertNullPointerException(() -> client.request((HttpMethod) null, 8080, "localhost", "/somepath", resp -> {
}));
TestUtils.assertNullPointerException(() -> client.request(HttpMethod.GET, 8080, null, "/somepath", resp -> {
}));
TestUtils.assertNullPointerException(() -> client.request(HttpMethod.GET, 8080, "localhost", null, resp -> {
}));
}
代码示例来源:origin: io.vertx/vertx-core
private void testSimpleRequest(String uri, HttpMethod method, boolean absolute, Handler<HttpClientResponse> handler) {
boolean ssl = this instanceof Http2Test;
HttpClientRequest req;
if (absolute) {
req = client.requestAbs(method, (ssl ? "https://" : "http://") + DEFAULT_HTTP_HOST + ":" + DEFAULT_HTTP_PORT + uri, handler);
} else {
req = client.request(method, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, uri, handler);
}
testSimpleRequest(uri, method, req, absolute);
}
代码示例来源:origin: io.vertx/vertx-core
@Test
public void testInvalidAbsoluteURI() {
try {
client.requestAbs(HttpMethod.GET, "ijdijwidjqwoijd192d192192ej12d", resp -> {
}).end();
fail("Should throw exception");
} catch (VertxException e) {
//OK
}
}
代码示例来源:origin: io.vertx/vertx-core
@Test
public void requestAbsNoPort() {
client.requestAbs(HttpMethod.GET, "http://www.google.com", res -> testComplete()).end();
await();
}
代码示例来源:origin: io.vertx/vertx-core
@Test
// Client trusts all server certs
public void testSSLClientRequestAbsSetSSL() throws Exception {
String absoluteURI = "https://" + DEFAULT_HTTP_HOST + ":4043/" + DEFAULT_TEST_URI;
testTLS(Cert.NONE, Trust.SERVER_JKS, Cert.SERVER_JKS, Trust.NONE).clientSSL(true).requestProvider(c -> c.requestAbs(HttpMethod.POST, absoluteURI)).pass();
}
代码示例来源:origin: io.vertx/vertx-core
@Test
// Client trusts all server certs
public void testClearClientRequestAbsSetSSL() throws Exception {
String absoluteURI = "https://" + DEFAULT_HTTP_HOST + ":4043/" + DEFAULT_TEST_URI;
testTLS(Cert.NONE, Trust.SERVER_JKS, Cert.SERVER_JKS, Trust.NONE).clientSSL(false).requestProvider(c -> c.requestAbs(HttpMethod.POST, absoluteURI)).pass();
}
代码示例来源:origin: io.vertx/vertx-core
@Test
// Client trusts all server certs
public void testSSLClientRequestAbsSetClear() throws Exception {
String absoluteURI = "http://" + DEFAULT_HTTP_HOST + ":4043/" + DEFAULT_TEST_URI;
testTLS(Cert.NONE, Trust.SERVER_JKS, Cert.SERVER_JKS, Trust.NONE).clientSSL(true).serverSSL(false).requestProvider(c -> c.requestAbs(HttpMethod.POST, absoluteURI)).pass();
}
代码示例来源:origin: io.vertx/vertx-core
@Test
// Client trusts all server certs
public void testClearClientRequestAbsSetClear() throws Exception {
String absoluteURI = "http://" + DEFAULT_HTTP_HOST + ":4043/" + DEFAULT_TEST_URI;
testTLS(Cert.NONE, Trust.SERVER_JKS, Cert.SERVER_JKS, Trust.NONE).clientSSL(false).serverSSL(false).requestProvider(c -> c.requestAbs(HttpMethod.POST, absoluteURI)).pass();
}
代码示例来源:origin: com.englishtown.vertx/vertx-when
@Override
public Promise<HttpClientResponse> requestAbs(HttpMethod method, String absoluteURI, RequestOptions options) {
RequestFunction func = client -> client.requestAbs(method, absoluteURI);
return doRequest(options, func);
}
代码示例来源:origin: ef-labs/vertx-when
@Override
public Promise<HttpClientResponse> requestAbs(HttpMethod method, String absoluteURI, RequestOptions options) {
RequestFunction func = client -> client.requestAbs(method, absoluteURI);
return doRequest(options, func);
}
代码示例来源:origin: io.vertx/vertx-rx-java
/**
* Create an HTTP request to send to the server using an absolute URI
* @param method the HTTP method
* @param absoluteURI the absolute URI
* @return an HTTP client request object
*/
public io.vertx.rxjava.core.http.HttpClientRequest requestAbs(HttpMethod method, String absoluteURI) {
io.vertx.rxjava.core.http.HttpClientRequest ret = io.vertx.rxjava.core.http.HttpClientRequest.newInstance(delegate.requestAbs(method, absoluteURI));
return ret;
}
代码示例来源:origin: io.vertx/vertx-core
@Test
public void testRequestNPE() {
String uri = "/some-uri?foo=bar";
TestUtils.assertNullPointerException(() -> client.request(HttpMethod.GET, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, uri, null));
TestUtils.assertNullPointerException(() -> client.request((HttpMethod)null, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, uri, resp -> {}));
TestUtils.assertNullPointerException(() -> client.requestAbs((HttpMethod) null, "http://someuri", resp -> {
}));
TestUtils.assertNullPointerException(() -> client.request(HttpMethod.GET, 8080, "localhost", "/somepath", null));
TestUtils.assertNullPointerException(() -> client.request((HttpMethod) null, 8080, "localhost", "/somepath", resp -> {
}));
TestUtils.assertNullPointerException(() -> client.request(HttpMethod.GET, 8080, null, "/somepath", resp -> {
}));
TestUtils.assertNullPointerException(() -> client.request(HttpMethod.GET, 8080, "localhost", null, resp -> {
}));
}
代码示例来源:origin: ef-labs/vertx-jersey
private void runHttpTest() {
vertx.createHttpClient()
.requestAbs(HttpMethod.GET, "http://localhost:8080/service", response -> {
assertEquals(200, response.statusCode());
testComplete();
})
.end();
}
内容来源于网络,如有侵权,请联系作者删除!