本文整理了Java中reactor.netty.http.client.HttpClient.request()
方法的一些代码示例,展示了HttpClient.request()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.request()
方法的具体详情如下:
包路径:reactor.netty.http.client.HttpClient
类名称:HttpClient
方法名:request
[英]Use the passed HTTP method to connect the HttpClient.
[中]使用传递的HTTP方法连接HttpClient。
代码示例来源:origin: spring-projects/spring-framework
@Override
public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
Function<? super ClientHttpRequest, Mono<Void>> requestCallback) {
if (!uri.isAbsolute()) {
return Mono.error(new IllegalArgumentException("URI is not absolute: " + uri));
}
return this.httpClient
.request(io.netty.handler.codec.http.HttpMethod.valueOf(method.name()))
.uri(uri.toString())
.send((request, outbound) -> requestCallback.apply(adaptRequest(method, uri, request, outbound)))
.responseConnection((res, con) -> Mono.just(adaptResponse(res, con.inbound(), con.outbound().alloc())))
.next();
}
代码示例来源:origin: org.springframework/spring-web
@Override
public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
Function<? super ClientHttpRequest, Mono<Void>> requestCallback) {
if (!uri.isAbsolute()) {
return Mono.error(new IllegalArgumentException("URI is not absolute: " + uri));
}
return this.httpClient
.request(io.netty.handler.codec.http.HttpMethod.valueOf(method.name()))
.uri(uri.toString())
.send((request, outbound) -> requestCallback.apply(adaptRequest(method, uri, request, outbound)))
.responseConnection((res, con) -> Mono.just(adaptResponse(res, con.inbound(), con.outbound().alloc())))
.next();
}
代码示例来源:origin: spring-cloud/spring-cloud-gateway
.request(method)
.uri(url)
.send((req, nettyOutbound) -> {
代码示例来源:origin: reactor/reactor-netty
/**
* HTTP DELETE to connect the {@link HttpClient}.
*
* @return a {@link RequestSender} ready to prepare the content for response
*/
public final RequestSender delete() {
return request(HttpMethod.DELETE);
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
/**
* HTTP HEAD to connect the {@link HttpClient}.
*
* @return a {@link RequestSender} ready to consume for response
*/
public final ResponseReceiver<?> head() {
return request(HttpMethod.HEAD);
}
代码示例来源:origin: reactor/reactor-netty
/**
* HTTP GET to connect the {@link HttpClient}.
*
* @return a {@link RequestSender} ready to consume for response
*/
public final ResponseReceiver<?> get() {
return request(HttpMethod.GET);
}
代码示例来源:origin: reactor/reactor-netty
/**
* HTTP HEAD to connect the {@link HttpClient}.
*
* @return a {@link RequestSender} ready to consume for response
*/
public final ResponseReceiver<?> head() {
return request(HttpMethod.HEAD);
}
代码示例来源:origin: reactor/reactor-netty
/**
* HTTP PATCH to connect the {@link HttpClient}.
*
* @return a {@link RequestSender} ready to finalize request and consume for response
*/
public final RequestSender patch() {
return request(HttpMethod.PATCH);
}
代码示例来源:origin: reactor/reactor-netty
/**
* HTTP PUT to connect the {@link HttpClient}.
*
* @return a {@link RequestSender} ready to finalize request and consume for response
*/
public final RequestSender put() {
return request(HttpMethod.PUT);
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
/**
* HTTP POST to connect the {@link HttpClient}.
*
* @return a {@link RequestSender} ready to finalize request and consume for response
*/
public final RequestSender post() {
return request(HttpMethod.POST);
}
代码示例来源:origin: reactor/reactor-netty
/**
* HTTP OPTIONS to connect the {@link HttpClient}.
*
* @return a {@link RequestSender} ready to consume for response
*/
public final ResponseReceiver<?> options() {
return request(HttpMethod.OPTIONS);
}
代码示例来源:origin: reactor/reactor-netty
/**
* HTTP POST to connect the {@link HttpClient}.
*
* @return a {@link RequestSender} ready to finalize request and consume for response
*/
public final RequestSender post() {
return request(HttpMethod.POST);
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
/**
* HTTP OPTIONS to connect the {@link HttpClient}.
*
* @return a {@link RequestSender} ready to consume for response
*/
public final ResponseReceiver<?> options() {
return request(HttpMethod.OPTIONS);
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
/**
* HTTP DELETE to connect the {@link HttpClient}.
*
* @return a {@link RequestSender} ready to prepare the content for response
*/
public final RequestSender delete() {
return request(HttpMethod.DELETE);
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
/**
* HTTP GET to connect the {@link HttpClient}.
*
* @return a {@link RequestSender} ready to consume for response
*/
public final ResponseReceiver<?> get() {
return request(HttpMethod.GET);
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
/**
* HTTP PATCH to connect the {@link HttpClient}.
*
* @return a {@link RequestSender} ready to finalize request and consume for response
*/
public final RequestSender patch() {
return request(HttpMethod.PATCH);
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
/**
* HTTP PUT to connect the {@link HttpClient}.
*
* @return a {@link RequestSender} ready to finalize request and consume for response
*/
public final RequestSender put() {
return request(HttpMethod.PUT);
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
Function<? super ClientHttpRequest, Mono<Void>> requestCallback) {
if (!uri.isAbsolute()) {
return Mono.error(new IllegalArgumentException("URI is not absolute: " + uri));
}
return this.httpClient
.request(adaptHttpMethod(method),
uri.toString(),
request -> requestCallback.apply(adaptRequest(method, uri, request)))
.map(this::adaptResponse);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-web
@Override
public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
Function<? super ClientHttpRequest, Mono<Void>> requestCallback) {
if (!uri.isAbsolute()) {
return Mono.error(new IllegalArgumentException("URI is not absolute: " + uri));
}
return this.httpClient
.request(io.netty.handler.codec.http.HttpMethod.valueOf(method.name()))
.uri(uri.toString())
.send((request, outbound) -> requestCallback.apply(adaptRequest(method, uri, request, outbound)))
.responseConnection((res, con) -> Mono.just(adaptResponse(res, con.inbound(), con.outbound().alloc())))
.next();
}
代码示例来源:origin: reactor/reactor-netty
@Test
public void disableChunkForced() {
Tuple2<HttpResponseStatus, String> r =
HttpClient.newConnection()
.tcpConfiguration(tcpClient -> tcpClient.host("google.com"))
.wiretap(true)
.chunkedTransfer(false)
.request(HttpMethod.GET)
.uri("/unsupportedURI")
.send(ByteBufFlux.fromString(Flux.just("hello")))
.responseSingle((res, conn) -> Mono.just(res.status())
.zipWith(conn.asString()))
.block(Duration.ofSeconds(30));
assertThat(r).isNotNull();
Assert.assertEquals(r.getT1(), HttpResponseStatus.NOT_FOUND);
}
内容来源于网络,如有侵权,请联系作者删除!