io.vertx.core.http.RequestOptions Java Examples
The following examples show how to use
io.vertx.core.http.RequestOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ListenerVertx.java From symbol-sdk-java with Apache License 2.0 | 6 votes |
/** * @return a {@link CompletableFuture} that resolves when the websocket connection is opened */ @Override public CompletableFuture<Void> open() { CompletableFuture<Void> future = new CompletableFuture<>(); if (this.webSocket != null) { return CompletableFuture.completedFuture(null); } RequestOptions requestOptions = new RequestOptions(); requestOptions.setHost(this.url.getHost()); requestOptions.setPort(this.url.getPort()); requestOptions.setURI("/ws"); httpClient.websocket( requestOptions, ws -> { this.webSocket = ws; ws.handler( handler -> { ObjectNode message = getJsonHelper() .convert(handler.toJsonObject(), ObjectNode.class); handle(message, future); }); }); return future; }
Example #2
Source File: MultipartRequestTest.java From vertx-web with Apache License 2.0 | 6 votes |
@Test public void testMultipleUploadMutation() { final HttpClient client = vertx.createHttpClient(getHttpClientOptions()); final Buffer bodyBuffer = vertx.fileSystem().readFileBlocking("multipleUpload.txt"); client.post(new RequestOptions() .setURI("/graphql") .addHeader("Content-Type", "multipart/form-data; boundary=----WebKitFormBoundaryhvb6BzAACEqQKt0Z") .addHeader("accept", "application/json") .setTimeout(10000), bodyBuffer, response -> response.result().bodyHandler(buffer -> { final JsonObject json = ((JsonObject) buffer.toJson()).getJsonObject("data").getJsonObject("multipleUpload"); assertEquals("b.txt c.txt", json.getString("id")); complete(); })); await(); }
Example #3
Source File: RestClientInvocation.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") void createRequest(IpPort ipPort, String path) { URIEndpointObject endpoint = (URIEndpointObject) invocation.getEndpoint().getAddress(); RequestOptions requestOptions = new RequestOptions(); requestOptions.setHost(ipPort.getHostOrIp()) .setPort(ipPort.getPort()) .setSsl(endpoint.isSslEnabled()) .setURI(path); HttpMethod method = getMethod(); invocation.getTraceIdLogger() .debug(LOGGER, "Sending request by rest, method={}, qualifiedName={}, path={}, endpoint={}.", method, invocation.getMicroserviceQualifiedName(), path, invocation.getEndpoint().getEndpoint()); clientRequest = httpClientWithContext.getHttpClient().request(method, requestOptions, this::handleResponse); }
Example #4
Source File: MultipartRequestTest.java From vertx-web with Apache License 2.0 | 6 votes |
@Test public void testSingleUploadMutation() { final HttpClient client = vertx.createHttpClient(getHttpClientOptions()); final Buffer bodyBuffer = vertx.fileSystem().readFileBlocking("singleUpload.txt"); client.post(new RequestOptions() .setURI("/graphql") .setTimeout(10000) .addHeader("Content-Type", "multipart/form-data; boundary=----WebKitFormBoundaryBpwmk50wSJmsTPAH") .addHeader("accept", "application/json"), bodyBuffer, response -> response.result().bodyHandler(buffer -> { final JsonObject json = ((JsonObject) buffer.toJson()).getJsonObject("data").getJsonObject("singleUpload"); assertEquals("a.txt", json.getString("id")); complete(); })); await(); }
Example #5
Source File: HttpConfigStore.java From vertx-config with Apache License 2.0 | 6 votes |
public HttpConfigStore(Vertx vertx, JsonObject configuration) { String host = configuration.getString("host"); int port = configuration.getInteger("port", 80); String path = configuration.getString("path", "/"); long timeout = configuration.getLong("timeout", 3000L); boolean followRedirects = configuration.getBoolean("followRedirects", false); this.client = vertx.createHttpClient(new HttpClientOptions(configuration)); this.requestOptions = new RequestOptions() .setHost(host) .setPort(port) .setURI(path) .setTimeout(timeout) .setFollowRedirects(followRedirects); configuration.getJsonObject("headers", new JsonObject()).stream() .filter(h -> h.getValue() != null) .forEach(h -> requestOptions.addHeader(h.getKey(), h.getValue().toString())); }
Example #6
Source File: SpringConfigServerStore.java From vertx-config with Apache License 2.0 | 6 votes |
@Override public void get(Handler<AsyncResult<Buffer>> completionHandler) { RequestOptions options = new RequestOptions().setURI(path).setTimeout(timeout); if (authHeaderValue != null) { options.addHeader("Authorization", authHeaderValue); } client.get(options, ar -> { if (ar.succeeded()) { HttpClientResponse response = ar.result(); if (response.statusCode() != 200) { completionHandler.handle(Future.failedFuture("Invalid response from server: " + response.statusCode() + " - " + response.statusMessage())); } else { response .exceptionHandler(t -> completionHandler.handle(Future.failedFuture(t))) .bodyHandler(buffer -> parse(buffer.toJsonObject(), completionHandler)); } } else { completionHandler.handle(Future.failedFuture(ar.cause())); } }); }
Example #7
Source File: CrudHttpClient.java From hono with Eclipse Public License 2.0 | 6 votes |
/** * Deletes a resource using an HTTP DELETE request. * * @param requestOptions The options to use for the request. * @param successPredicate A predicate on the returned HTTP status code for determining success. * @return A future that will succeed if the predicate evaluates to {@code true}. * @throws NullPointerException if options or predicate are {@code null}. */ public Future<Void> delete(final RequestOptions requestOptions, final IntPredicate successPredicate) { Objects.requireNonNull(requestOptions); Objects.requireNonNull(successPredicate); final Promise<Void> result = Promise.promise(); context.runOnContext(go -> { @SuppressWarnings("deprecation") final HttpClientRequest req = client.delete(requestOptions) .handler(response -> { LOGGER.debug("got response [status: {}]", response.statusCode()); if (successPredicate.test(response.statusCode())) { checkCorsHeaders(response, result); result.tryComplete(); } else { result.tryFail(newUnexpectedResponseStatusException(response.statusCode())); } }).exceptionHandler(result::tryFail); req.headers().add(HttpHeaders.ORIGIN, ORIGIN_URI); req.end(); }); return result.future(); }
Example #8
Source File: MetaWeatherClient.java From tutorials with MIT License | 5 votes |
static Flowable<HttpClientResponse> searchByCityName(HttpClient httpClient, String cityName) { HttpClientRequest req = httpClient.get( new RequestOptions() .setHost("www.metaweather.com") .setPort(443) .setSsl(true) .setURI(format("/api/location/search/?query=%s", cityName))); return req .toFlowable() .doOnSubscribe(subscription -> req.end()); }
Example #9
Source File: WebSocketServiceLoginTest.java From besu with Apache License 2.0 | 5 votes |
@Test public void websocketServiceWithBadHeaderAuthenticationToken(final TestContext context) { final Async async = context.async(); final String request = "{\"id\": 1, \"method\": \"eth_subscribe\", \"params\": [\"syncing\"]}"; final String expectedResponse = "{\"jsonrpc\":\"2.0\",\"id\":1,\"error\":{\"code\":-40100,\"message\":\"Unauthorized\"}}"; RequestOptions options = new RequestOptions(); options.setURI("/"); options.setHost(websocketConfiguration.getHost()); options.setPort(websocketConfiguration.getPort()); final MultiMap headers = new VertxHttpHeaders(); String badtoken = "badtoken"; if (badtoken != null) { headers.add("Authorization", "Bearer " + badtoken); } httpClient.websocket( options, headers, webSocket -> { webSocket.writeTextMessage(request); webSocket.handler( buffer -> { context.assertEquals(expectedResponse, buffer.toString()); async.complete(); }); }); async.awaitSuccess(VERTX_AWAIT_TIMEOUT_MILLIS); }
Example #10
Source File: ApiWebTestBase.java From vertx-web with Apache License 2.0 | 5 votes |
public void testRequestWithBufferResponse(HttpMethod method, String path, String contentType, Buffer obj, int statusCode, String statusMessage, String expectedContentType, Consumer<Buffer> checkResult) throws Exception { CountDownLatch latch = new CountDownLatch(1); RequestOptions options = new RequestOptions() .setMethod(method) .setPort(8080) .setHost("localhost") .setURI(path); if (contentType != null) { options.addHeader(HttpHeaders.CONTENT_TYPE, contentType); } client .send(options, obj, onSuccess(res -> { if (checkResult != null) { assertEquals(statusCode, res.statusCode()); assertEquals(statusMessage, res.statusMessage()); assertEquals(expectedContentType, res.getHeader(HttpHeaders.CONTENT_TYPE)); res.bodyHandler(buff -> { buff = normalizeLineEndingsFor(buff); checkResult.accept(buff); latch.countDown(); }); } else { assertEquals(statusCode, res.statusCode()); assertEquals(statusMessage, res.statusMessage()); latch.countDown(); } })); awaitLatch(latch); }
Example #11
Source File: CrudHttpClient.java From hono with Eclipse Public License 2.0 | 5 votes |
/** * Retrieves a resource representation using an HTTP GET request. * * @param requestOptions The options to use for the request. * @param successPredicate A predicate on the returned HTTP status code for determining success. * @return A future that will succeed if the predicate evaluates to {@code true}. In that case the * future will contain the response body. * @throws NullPointerException if options or predicate are {@code null}. */ public Future<Buffer> get(final RequestOptions requestOptions, final IntPredicate successPredicate) { Objects.requireNonNull(requestOptions); Objects.requireNonNull(successPredicate); final Promise<Buffer> result = Promise.promise(); context.runOnContext(go -> { @SuppressWarnings("deprecation") final HttpClientRequest req = client.get(requestOptions) .handler(response -> { if (successPredicate.test(response.statusCode())) { if (response.statusCode() < 400) { checkCorsHeaders(response, result); } response.bodyHandler(body -> result.tryComplete(body)); } else { result.tryFail(newUnexpectedResponseStatusException(response.statusCode())); } }).exceptionHandler(result::tryFail); req.headers().add(HttpHeaders.ORIGIN, ORIGIN_URI); req.end(); }); return result.future(); }
Example #12
Source File: CrudHttpClient.java From hono with Eclipse Public License 2.0 | 5 votes |
/** * Gets options for a resource using an HTTP OPTIONS request. * * @param requestOptions The options to use for the request. * @param requestHeaders The headers to include in the request. * @param successPredicate A predicate on the returned HTTP status code for determining success. * @return A future that will succeed if the predicate evaluates to {@code true}. In that case the * future will contain the response headers. * @throws NullPointerException if options or predicate are {@code null}. */ public Future<MultiMap> options( final RequestOptions requestOptions, final MultiMap requestHeaders, final IntPredicate successPredicate) { Objects.requireNonNull(requestOptions); Objects.requireNonNull(successPredicate); final Promise<MultiMap> result = Promise.promise(); context.runOnContext(go -> { @SuppressWarnings("deprecation") final HttpClientRequest req = client.options(requestOptions) .handler(response -> { if (successPredicate.test(response.statusCode())) { result.tryComplete(response.headers()); } else { result.tryFail(newUnexpectedResponseStatusException(response.statusCode())); } }).exceptionHandler(result::tryFail); if (requestHeaders != null) { req.headers().addAll(requestHeaders); } req.end(); }); return result.future(); }
Example #13
Source File: TestRestClientInvocation.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@SuppressWarnings({"unchecked", "deprecation"}) @Before public void setup() { Deencapsulation.setField(restClientInvocation, "clientRequest", request); Deencapsulation.setField(restClientInvocation, "invocation", invocation); Deencapsulation.setField(restClientInvocation, "asyncResp", asyncResp); when(invocation.getMicroserviceName()).thenReturn(TARGET_MICROSERVICE_NAME); when(invocation.getOperationMeta()).thenReturn(operationMeta); when(swaggerRestOperation.getPathBuilder()).thenReturn(urlPathBuilder); when(swaggerRestOperation.getHttpMethod()).thenReturn("GET"); when(operationMeta.getExtData(RestConst.SWAGGER_REST_OPERATION)).thenReturn(swaggerRestOperation); when(operationMeta.getConfig()).thenReturn(operationConfig); when(invocation.getEndpoint()).thenReturn(endpoint); when(invocation.getTraceIdLogger()).thenReturn(new TraceIdLogger(invocation)); when(endpoint.getAddress()).thenReturn(address); when(invocation.getHandlerContext()).then(answer -> handlerContext); when(invocation.getInvocationStageTrace()).thenReturn(invocationStageTrace); when(httpClient.request(Mockito.any(), (RequestOptions) Mockito.any(), Mockito.any())) .thenReturn(request); when(request.headers()).thenReturn(headers); doAnswer(a -> { exceptionHandler = (Handler<Throwable>) a.getArguments()[0]; return request; }).when(request).exceptionHandler(any()); doAnswer(a -> { headers.add(a.getArgumentAt(0, String.class), a.getArgumentAt(1, String.class)); return request; }).when(request).putHeader(any(), (String) any()); doAnswer(a -> { ((Handler<Void>) a.getArguments()[0]).handle(null); return null; }).when(context).runOnContext(any()); }
Example #14
Source File: WebSocketConnection.java From besu with Apache License 2.0 | 5 votes |
public WebSocketConnection(final Vertx vertx, final NodeConfiguration node) { if (!node.getJsonRpcWebSocketPort().isPresent()) { throw new IllegalStateException( "Can't start websocket connection for node with RPC disabled"); } subscriptionEvents = new ConcurrentLinkedDeque<>(); options = new RequestOptions(); options.setPort(node.getJsonRpcWebSocketPort().get()); options.setHost(node.getHostName()); connect(vertx); }
Example #15
Source File: WebSocketServiceLoginTest.java From besu with Apache License 2.0 | 5 votes |
@Test public void websocketServiceWithGoodHeaderAuthenticationToken(final TestContext context) { final Async async = context.async(); final JWTOptions jwtOptions = new JWTOptions().setExpiresInMinutes(5).setAlgorithm("RS256"); final JsonObject jwtContents = new JsonObject().put("permissions", Lists.newArrayList("eth:*")).put("username", "user"); final String goodToken = jwtAuth.generateToken(jwtContents, jwtOptions); final String requestSub = "{\"id\": 1, \"method\": \"eth_subscribe\", \"params\": [\"syncing\"]}"; final String expectedResponse = "{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":\"0x1\"}"; RequestOptions options = new RequestOptions(); options.setURI("/"); options.setHost(websocketConfiguration.getHost()); options.setPort(websocketConfiguration.getPort()); final MultiMap headers = new VertxHttpHeaders(); if (goodToken != null) { headers.add("Authorization", "Bearer " + goodToken); } httpClient.websocket( options, headers, webSocket -> { webSocket.writeTextMessage(requestSub); webSocket.handler( buffer -> { context.assertEquals(expectedResponse, buffer.toString()); async.complete(); }); }); async.awaitSuccess(VERTX_AWAIT_TIMEOUT_MILLIS); }
Example #16
Source File: CrudHttpClient.java From hono with Eclipse Public License 2.0 | 4 votes |
/** * Updates a resource using an HTTP PUT request. * * @param requestOptions The options to use for the request. * @param body The content to update the resource with. * @param requestHeaders The headers to include in the request. * @param successPredicate A predicate on the response for determining success. * @param checkCorsHeaders Whether to set and check CORS headers. * @return A future that will succeed if the predicate evaluates to {@code true}. * @throws NullPointerException if options or predicate are {@code null}. */ public Future<MultiMap> update( final RequestOptions requestOptions, final Buffer body, final MultiMap requestHeaders, final IntPredicate successPredicate, final boolean checkCorsHeaders) { Objects.requireNonNull(requestOptions); Objects.requireNonNull(successPredicate); final Promise<MultiMap> result = Promise.promise(); context.runOnContext(go -> { @SuppressWarnings("deprecation") final HttpClientRequest req = client.put(requestOptions) .handler(response -> { if (successPredicate.test(response.statusCode())) { if (checkCorsHeaders) { checkCorsHeaders(response, result); } result.tryComplete(response.headers()); } else { result.tryFail(newUnexpectedResponseStatusException(response.statusCode())); } }).exceptionHandler(result::tryFail); if (requestHeaders != null) { req.headers().addAll(requestHeaders); } if (checkCorsHeaders) { req.headers().add(HttpHeaders.ORIGIN, ORIGIN_URI); } if (body == null) { req.end(); } else { req.end(body); } }); return result.future(); }
Example #17
Source File: CrudHttpClient.java From hono with Eclipse Public License 2.0 | 4 votes |
/** * Creates a resource using an HTTP POST request. * * @param requestOptions The options to use for the request. * @param body The body to post (may be {@code null}). * @param requestHeaders The headers to include in the request (may be {@code null}). * @param successPredicate A predicate on the HTTP response for determining success. * @param checkCorsHeaders Whether to set and check CORS headers. * @return A future that will succeed if the predicate evaluates to {@code true}. * @throws NullPointerException if options or predicate are {@code null}. */ public Future<MultiMap> create( final RequestOptions requestOptions, final Buffer body, final MultiMap requestHeaders, final Predicate<HttpClientResponse> successPredicate, final boolean checkCorsHeaders) { Objects.requireNonNull(requestOptions); Objects.requireNonNull(successPredicate); final Promise<MultiMap> result = Promise.promise(); context.runOnContext(go -> { @SuppressWarnings("deprecation") final HttpClientRequest req = client.post(requestOptions) .handler(response -> { LOGGER.trace("response status code {}", response.statusCode()); if (successPredicate.test(response)) { if (checkCorsHeaders) { checkCorsHeaders(response, result); } result.tryComplete(response.headers()); } else { result.tryFail(newUnexpectedResponseStatusException(response.statusCode())); } }).exceptionHandler(result::tryFail); if (requestHeaders != null) { req.headers().addAll(requestHeaders); } if (checkCorsHeaders) { req.headers().add(HttpHeaders.ORIGIN, ORIGIN_URI); } if (body == null) { req.end(); } else { req.end(body); } }); return result.future(); }
Example #18
Source File: CrudHttpClient.java From hono with Eclipse Public License 2.0 | 4 votes |
private RequestOptions createRequestOptions() { return new RequestOptions() .setSsl(options.isSsl()) .setHost(options.getDefaultHost()) .setPort(options.getDefaultPort()); }
Example #19
Source File: ListenerVertxTest.java From symbol-sdk-java with Apache License 2.0 | 4 votes |
private void simulateWebSocketStartup() throws InterruptedException, ExecutionException, TimeoutException { ArgumentCaptor<Handler> webSocketHandlerCapture = ArgumentCaptor.forClass(Handler.class); ArgumentCaptor<Handler> bufferHandlerCapture = ArgumentCaptor.forClass(Handler.class); when(httpClientMock.websocket(any(RequestOptions.class), webSocketHandlerCapture.capture())) .thenReturn(httpClientMock); when(webSocketMock.handler(bufferHandlerCapture.capture())).thenReturn(webSocketMock); CompletableFuture<Void> future = listener.open(); Handler<WebSocket> webSocketHandler = webSocketHandlerCapture.getValue(); Assertions.assertNotNull(webSocketHandler); webSocketHandler.handle(webSocketMock); Handler<Buffer> bufferHandler = bufferHandlerCapture.getValue(); Assertions.assertNotNull(bufferHandler); Buffer event = new BufferFactoryImpl().buffer(jsonHelper.print(Collections.singletonMap("uid", wsId))); bufferHandler.handle(event); future.get(3, TimeUnit.SECONDS); }
Example #20
Source File: WebClientBase.java From vertx-web with Apache License 2.0 | 4 votes |
@Override public HttpRequest<Buffer> request(HttpMethod method, RequestOptions requestOptions) { return request(method, null, requestOptions); }
Example #21
Source File: WebClientBase.java From vertx-web with Apache License 2.0 | 4 votes |
@Override public HttpRequest<Buffer> request(HttpMethod method, SocketAddress serverAddress, RequestOptions requestOptions) { return new HttpRequestImpl<>(this, method, serverAddress, requestOptions.isSsl(), requestOptions.getPort(), requestOptions.getHost(), requestOptions.getURI(), BodyCodecImpl.BUFFER, options); }
Example #22
Source File: OpenIDConnectAuth.java From vertx-auth with Apache License 2.0 | 4 votes |
/** * Create a OAuth2Auth provider for OpenID Connect Discovery. The discovery will use the given site in the * configuration options and attempt to load the well known descriptor. * <p> * If the discovered config includes a json web key url, it will be also fetched and the JWKs will be loaded * into the OAuth provider so tokens can be decoded. * * @param vertx the vertx instance * @param config the initial config, it should contain a site url * @param handler the instantiated Oauth2 provider instance handler */ static void discover(final Vertx vertx, final OAuth2Options config, final Handler<AsyncResult<OAuth2Auth>> handler) { if (config.getSite() == null) { handler.handle(Future.failedFuture("issuer cannot be null")); return; } // compute paths with variables, at this moment it is only relevant that // the paths and site are properly computed config.replaceVariables(false); final OAuth2API api = new OAuth2API(vertx, config); // the response follows the OpenID Connect provider metadata spec: // https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata RequestOptions options = new RequestOptions() .setMethod(HttpMethod.GET) .setAbsoluteURI(config.getSite() + "/.well-known/openid-configuration") .addHeader("Accept", "application/json"); api.makeRequest(options, null, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); return; } final OAuth2Response response = res.result(); if (response.statusCode() != 200) { handler.handle(Future.failedFuture("Bad Response [" + response.statusCode() + "] " + response.body())); return; } if (!response.is("application/json")) { handler.handle(Future.failedFuture("Cannot handle Content-Type: " + response.headers().get("Content-Type"))); return; } final JsonObject json = response.jsonObject(); // issuer validation if (config.isValidateIssuer()) { String issuerEndpoint = json.getString("issuer"); if (issuerEndpoint != null) { // the provider is letting the user know the issuer endpoint, so we need to validate // as in vertx oauth the issuer (site config) is a url without the trailing slash we // will compare the received endpoint without the final slash is present if (issuerEndpoint.endsWith("/")) { issuerEndpoint = issuerEndpoint.substring(0, issuerEndpoint.length() - 1); } if (!config.getSite().equals(issuerEndpoint)) { handler.handle(Future.failedFuture("issuer validation failed: received [" + issuerEndpoint + "]")); return; } } } config.setAuthorizationPath(json.getString("authorization_endpoint")); config.setTokenPath(json.getString("token_endpoint")); config.setLogoutPath(json.getString("end_session_endpoint")); config.setRevocationPath(json.getString("revocation_endpoint")); config.setUserInfoPath(json.getString("userinfo_endpoint")); config.setJwkPath(json.getString("jwks_uri")); try { // the constructor might fail if the configuration is incomplete final OAuth2Auth oidc = OAuth2Auth.create(vertx, config); if (config.getJwkPath() != null) { oidc.jWKSet(v -> { if (v.failed()) { handler.handle(Future.failedFuture(v.cause())); return; } handler.handle(Future.succeededFuture(oidc)); }); } else { handler.handle(Future.succeededFuture(oidc)); } } catch (IllegalArgumentException | IllegalStateException e) { handler.handle(Future.failedFuture(e)); } }); }
Example #23
Source File: MetaWeatherClient.java From tutorials with MIT License | 4 votes |
/** * @return A flowable backed by vertx that automatically sends an HTTP request at soon as the first subscription is received. */ private static Flowable<HttpClientResponse> autoPerformingReq(HttpClient httpClient, String uri) { HttpClientRequest req = httpClient.get(new RequestOptions(metawether).setURI(uri)); return req.toFlowable() .doOnSubscribe(subscription -> req.end()); }
Example #24
Source File: WebClient.java From vertx-web with Apache License 2.0 | 2 votes |
/** * Create an HTTP request to send to the server at the specified host and port. * @param method the HTTP method * @param options the request options * @return an HTTP client request object */ HttpRequest<Buffer> request(HttpMethod method, RequestOptions options);
Example #25
Source File: WebClient.java From vertx-web with Apache License 2.0 | 2 votes |
/** * Like {@link #request(HttpMethod, RequestOptions)} using the {@code serverAddress} parameter to connect to the * server instead of the {@code options} parameter. * <p> * The request host header will still be created from the {@code options} parameter. * <p> * Use {@link SocketAddress#domainSocketAddress(String)} to connect to a unix domain socket server. */ HttpRequest<Buffer> request(HttpMethod method, SocketAddress serverAddress, RequestOptions options);