@Override public void start() throws Exception { WebClient client = WebClient.create(vertx); client.get(8080, "localhost", "/") .addQueryParam("firstName", "Dale") .addQueryParam("lastName", "Cooper") .addQueryParam("male", "true") .send(ar -> { if (ar.succeeded()) { HttpResponse<Buffer> response = ar.result(); System.out.println("Got HTTP response with status " + response.statusCode()); } else { ar.cause().printStackTrace(); } }); } }
client.postAbs(AUTH_URL) .as(BodyCodec.jsonObject()) .addQueryParam("grant_type", "client_credentials") .putHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8") .putHeader("Authorization", authHeader) .addQueryParam("q", queryToSearch) .putHeader("Authorization", header) .send(handler -> {
/** * Add a query parameter to the request. * @param paramName the param name * @param paramValue the param value * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.client.HttpRequest<T> addQueryParam(String paramName, String paramValue) { delegate.addQueryParam(paramName, paramValue); return this; }
/** * Add a query parameter to the request. * @param paramName the param name * @param paramValue the param value * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.client.HttpRequest<T> addQueryParam(String paramName, String paramValue) { delegate.addQueryParam(paramName, paramValue); return this; }
private <T> HttpRequest<T> addRequestParameters(HttpRequest<T> request, Optional<HashMap<String, String>> params) { if (params.isPresent()) { params.get().entrySet().iterator().forEachRemaining( stringStringEntry -> request.addQueryParam(stringStringEntry.getKey(), stringStringEntry.getValue())); } return request; }
query.entrySet().forEach(e -> rq.addQueryParam(e.getKey(), e.getValue())); if (aclToken != null) { rq.putHeader(TOKEN_HEADER, aclToken);
/** * Regression test for issue #563 (https://github.com/vert-x3/vertx-web/issues/563) * <p> * Only occurred when {@link WebClientOptions#isSsl()} was false for an SSL request. */ @Test public void testTLSQueryParametersIssue563() throws Exception { testTLS(false, true, client -> client.getAbs("https://" + DEFAULT_HTTPS_HOST + ":" + DEFAULT_HTTPS_PORT) .addQueryParam("query1", "value1") .addQueryParam("query2", "value2"), serverRequest -> assertEquals("query1=value1&query2=value2", serverRequest.query())); }
@Test public void testQueryParamMulti() throws Exception { testRequest(client -> client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/").addQueryParam("param", "param_value1").addQueryParam("param", "param_value2"), req -> { assertEquals("param=param_value1¶m=param_value2", req.query()); assertEquals(Arrays.asList("param_value1", "param_value2"), req.params().getAll("param")); }); }
.addQueryParam("watch", "true") .addQueryParam("resourceVersion", resourceVersion) .as(BodyCodec.pipe(new WriteStream<Buffer>() { @Override
@Test public void testQueryParamEncoding() throws Exception { testRequest(client -> client .get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/") .addQueryParam("param1", " ") .addQueryParam("param2", "\u20AC"), req -> { assertEquals("param1=%20¶m2=%E2%82%AC", req.query()); assertEquals(" ", req.getParam("param1")); assertEquals("\u20AC", req.getParam("param2")); }); }
@Test public void testQueryParamAppend() throws Exception { testRequest(client -> client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/?param1=param1_value1").addQueryParam("param1", "param1_value2").addQueryParam("param2", "param2_value"), req -> { assertEquals("param1=param1_value1¶m1=param1_value2¶m2=param2_value", req.query()); assertEquals("param1_value1", req.getParam("param1")); assertEquals("param2_value", req.getParam("param2")); }); }
@Test public void testQueryParam() throws Exception { testRequest(client -> client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/").addQueryParam("param", "param_value"), req -> { assertEquals("param=param_value", req.query()); assertEquals("param_value", req.getParam("param")); }); }
.addQueryParam("c", "X");