本文整理了Java中reactor.netty.http.client.HttpClient.chunkedTransfer()
方法的一些代码示例,展示了HttpClient.chunkedTransfer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.chunkedTransfer()
方法的具体详情如下:
包路径:reactor.netty.http.client.HttpClient
类名称:HttpClient
方法名:chunkedTransfer
[英]Specifies whether transfer-encoding is enabled
[中]指定是否启用传输编码
代码示例来源:origin: spring-cloud/spring-cloud-gateway
.chunkedTransfer(chunkedTransfer)
.request(method)
.uri(url)
代码示例来源:origin: com.rabbitmq/http-client
private Mono<HttpResponse> doPut(String... pathSegments) {
return client.headersWhen(authorizedHeader())
.headers(JSON_HEADER)
.chunkedTransfer(false)
.put()
.uri(uri(pathSegments))
.response()
.doOnNext(applyResponseCallback())
.map(ReactorNettyClient::toHttpResponse);
}
代码示例来源:origin: rabbitmq/hop
private Mono<HttpResponse> doPut(String... pathSegments) {
return client.headersWhen(authorizedHeader())
.headers(JSON_HEADER)
.chunkedTransfer(false)
.put()
.uri(uri(pathSegments))
.response()
.doOnNext(applyResponseCallback())
.map(ReactorNettyClient::toHttpResponse);
}
代码示例来源:origin: com.rabbitmq/http-client
private Mono<HttpResponse> doPut(Object body, String... pathSegments) {
return client.headersWhen(authorizedHeader())
.chunkedTransfer(false)
.put()
.uri(uri(pathSegments))
.send(bodyPublisher(body))
.response()
.doOnNext(applyResponseCallback())
.map(ReactorNettyClient::toHttpResponse);
}
代码示例来源:origin: rabbitmq/hop
private Mono<HttpResponse> doPut(Object body, String... pathSegments) {
return client.headersWhen(authorizedHeader())
.chunkedTransfer(false)
.put()
.uri(uri(pathSegments))
.send(bodyPublisher(body))
.response()
.doOnNext(applyResponseCallback())
.map(ReactorNettyClient::toHttpResponse);
}
代码示例来源:origin: rabbitmq/hop
private Mono<HttpResponse> doPost(Object body, String... pathSegments) {
return client.headersWhen(authorizedHeader())
.headers(JSON_HEADER)
.chunkedTransfer(false)
.post()
.uri(uri(pathSegments))
.send(bodyPublisher(body))
.response()
.doOnNext(applyResponseCallback())
.map(ReactorNettyClient::toHttpResponse);
}
代码示例来源:origin: com.rabbitmq/http-client
private Mono<HttpResponse> doPost(Object body, String... pathSegments) {
return client.headersWhen(authorizedHeader())
.headers(JSON_HEADER)
.chunkedTransfer(false)
.post()
.uri(uri(pathSegments))
.send(bodyPublisher(body))
.response()
.doOnNext(applyResponseCallback())
.map(ReactorNettyClient::toHttpResponse);
}
代码示例来源:origin: reactor/reactor-netty
@Test
public void disableChunkForced2() {
Tuple2<HttpResponseStatus, String> r =
HttpClient.newConnection()
.tcpConfiguration(tcpClient -> tcpClient.host("google.com"))
.wiretap(true)
.keepAlive(false)
.chunkedTransfer(false)
.get()
.uri("/unsupportedURI")
.responseSingle((res, conn) -> Mono.just(res.status())
.zipWith(conn.asString()))
.block(Duration.ofSeconds(30));
assertThat(r).isNotNull();
Assert.assertEquals(r.getT1(), HttpResponseStatus.NOT_FOUND);
}
代码示例来源: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);
}
代码示例来源:origin: reactor/reactor-netty
@Test
public void testPreferContentLengthWhenPost() {
DisposableServer server =
HttpServer.create()
.port(0)
.wiretap(true)
.handle((req, res) ->
res.header(HttpHeaderNames.CONTENT_LENGTH,
req.requestHeaders()
.get(HttpHeaderNames.CONTENT_LENGTH))
.send(req.receive()
.aggregate()
.retain()))
.bindNow();
StepVerifier.create(
createHttpClientForContextWithAddress(server)
.chunkedTransfer(false)
.headers(h -> h.add(HttpHeaderNames.CONTENT_LENGTH, 5))
.post()
.uri("/")
.send(Mono.just(Unpooled.wrappedBuffer("hello".getBytes(Charset.defaultCharset()))))
.responseContent()
.aggregate()
.asString())
.expectNextMatches("hello"::equals)
.expectComplete()
.verify(Duration.ofSeconds(30));
server.disposeNow();
}
代码示例来源:origin: reactor/reactor-netty
@Test
public void disableChunkImplicitDefault() {
ConnectionProvider p = ConnectionProvider.fixed("test", 1);
HttpClient client =
HttpClient.create(p)
.tcpConfiguration(tcpClient -> tcpClient.host("google.com"))
.wiretap(true)
.chunkedTransfer(false);
Tuple2<HttpResponseStatus, Channel> r =
client.get()
.uri("/unsupportedURI")
.responseConnection((res, conn) -> Mono.just(res.status())
.delayUntil(s -> conn.inbound().receive())
.zipWith(Mono.just(conn.channel())))
.blockLast(Duration.ofSeconds(30));
assertThat(r).isNotNull();
Channel r2 =
client.get()
.uri("/unsupportedURI")
.responseConnection((res, conn) -> Mono.just(conn.channel())
.delayUntil(s -> conn.inbound().receive()))
.blockLast(Duration.ofSeconds(30));
assertThat(r2).isNotNull();
Assert.assertSame(r.getT2(), r2);
Assert.assertEquals(r.getT1(), HttpResponseStatus.NOT_FOUND);
p.dispose();
}
内容来源于网络,如有侵权,请联系作者删除!