/** * HTTP GET the passed URL. When connection has been made, the passed handler is * invoked and can be used to tune the request and write data to it. * * @param url the target remote URL * @param handler the {@link Function} to invoke on open channel * @return a {@link Mono} of the {@link HttpServerResponse} ready to consume for * response */ public final Mono<HttpClientResponse> get(String url, Function<? super HttpClientRequest, ? extends Publisher<Void>> handler) { return request(HttpMethod.GET, url, handler); }
/** * WebSocket to the passed URL. * * @param url the target remote URL * @return a {@link Mono} of the {@link HttpServerResponse} ready to consume for * response */ public final Mono<HttpClientResponse> ws(String url) { return request(WS, url, HttpClientRequest::sendWebsocket); }
/** * HTTP DELETE the passed URL. * * @param url the target remote URL * @return a {@link Mono} of the {@link HttpServerResponse} ready to consume for * response */ public final Mono<HttpClientResponse> delete(String url) { return request(HttpMethod.DELETE, url, null); }
/** * HTTP PATCH the passed URL. * * @param url the target remote URL * @return a {@link Mono} of the {@link HttpServerResponse} ready to consume for * response */ public final Mono<HttpClientResponse> patch(String url) { return request(HttpMethod.PATCH, url, null); }
/** * HTTP PATCH the passed URL. When connection has been made, the passed handler is * invoked and can be used to tune the request and write data to it. * * @param url the target remote URL * @param handler the {@link Function} to invoke on open channel * @return a {@link Mono} of the {@link HttpServerResponse} ready to consume for * response */ public final Mono<HttpClientResponse> patch(String url, Function<? super HttpClientRequest, ? extends Publisher<Void>> handler) { return request(HttpMethod.PATCH, url, handler); }
/** * HTTP GET the passed URL. * * @param url the target remote URL * @return a {@link Mono} of the {@link HttpServerResponse} ready to consume for * response */ public final Mono<HttpClientResponse> get(String url) { return request(HttpMethod.GET, url, null); }
/** * HTTP PUT the passed URL. When connection has been made, the passed handler is * invoked and can be used to tune the request and write data to it. * * @param url the target remote URL * @param handler the {@link Function} to invoke on open channel * @return a {@link Mono} of the {@link HttpServerResponse} ready to consume for * response */ public final Mono<HttpClientResponse> put(String url, Function<? super HttpClientRequest, ? extends Publisher<Void>> handler) { return request(HttpMethod.PUT, url, handler); }
/** * HTTP DELETE the passed URL. When connection has been established, the passed handler is * invoked and can be used to tune the request and write data to it. * * @param url the target remote URL * @param handler the {@link Function} to invoke on open channel * @return a {@link Mono} of the {@link HttpServerResponse} ready to consume for * response */ public final Mono<HttpClientResponse> delete(String url, Function<? super HttpClientRequest, ? extends Publisher<Void>> handler) { return request(HttpMethod.DELETE, url, handler); }
/** * HTTP POST the passed URL. When connection has been made, the passed handler is * invoked and can be used to tune the request and write data to it. * * @param url the target remote URL * @param handler the {@link Function} to invoke on open channel * @return a {@link Mono} of the {@link HttpServerResponse} ready to consume for * response */ public final Mono<HttpClientResponse> post(String url, Function<? super HttpClientRequest, ? extends Publisher<Void>> handler) { return request(HttpMethod.POST, url, handler); }
/** * WebSocket to the passed URL, negotiating one of the passed subprotocols. * <p> * The negotiated subprotocol can be accessed through the {@link HttpClientResponse} * by switching to websocket (using any of the {@link HttpClientResponse#receiveWebsocket() receiveWebSocket} * methods) and using {@link WebsocketInbound#selectedSubprotocol()}. * <p> * To send data through the websocket, use {@link HttpClientResponse#receiveWebsocket(BiFunction)} * and then use the function's {@link WebsocketOutbound}. * * @param url the target remote URL * @param subprotocols the subprotocol(s) to negotiate, comma-separated, or null if not relevant. * @return a {@link Mono} of the {@link HttpServerResponse} ready to consume for * response */ public final Mono<HttpClientResponse> ws(String url, String subprotocols) { return request(WS, url, req -> req.sendWebsocket(subprotocols)); }
/** * WebSocket to the passed URL. * * @param url the target remote URL * @param headerBuilder the header {@link Consumer} to invoke before sending websocket * handshake * @return a {@link Mono} of the {@link HttpServerResponse} ready to consume for * response */ public final Mono<HttpClientResponse> ws(String url, final Consumer<? super HttpHeaders> headerBuilder) { return request(WS, url, ch -> { headerBuilder.accept(ch.requestHeaders()); return ch.sendWebsocket(); }); } /**
/** * WebSocket to the passed URL, negotiating one of the passed subprotocols. * <p> * The negotiated subprotocol can be accessed through the {@link HttpClientResponse} * by switching to websocket (using any of the {@link HttpClientResponse#receiveWebsocket() receiveWebSocket} * methods) and using {@link WebsocketInbound#selectedSubprotocol()}. * <p> * To send data through the websocket, use {@link HttpClientResponse#receiveWebsocket(BiFunction)} * and then use the function's {@link WebsocketOutbound}. * * @param url the target remote URL * @param headerBuilder the header {@link Consumer} to invoke before sending websocket * handshake * @param subprotocols the subprotocol(s) to negotiate, comma-separated, or null if not relevant. * @return a {@link Mono} of the {@link HttpServerResponse} ready to consume for * response */ public final Mono<HttpClientResponse> ws(String url, final Consumer<? super HttpHeaders> headerBuilder, String subprotocols) { return request(WS, url, ch -> { headerBuilder.accept(ch.requestHeaders()); return ch.sendWebsocket(subprotocols); }); }