Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Reactor Netty HttpClient发送DefaultFullHttpRequest_Netty_Reactor Netty - Fatal编程技术网

使用Reactor Netty HttpClient发送DefaultFullHttpRequest

使用Reactor Netty HttpClient发送DefaultFullHttpRequest,netty,reactor-netty,Netty,Reactor Netty,我正试图向反应堆Netty HttpServer发送一条大消息。 消息为1511字节,根据HttpClient日志记录已成功写入,但服务器端仅读取1024字节。这是因为标题中没有内容长度 Reactor Netty有几个发送选项,适用于我的帖子的是send或sendObject。send方法只提供发送ByteBuf的选项,而DefaultFullHttpRequest不提供转换为ByteBuf的方法,因此我不能包含头 ByteBuf reqContent = getTestRequest();

我正试图向反应堆Netty HttpServer发送一条大消息。 消息为1511字节,根据HttpClient日志记录已成功写入,但服务器端仅读取1024字节。这是因为标题中没有内容长度

Reactor Netty有几个发送选项,适用于我的帖子的是send或sendObject。send方法只提供发送ByteBuf的选项,而DefaultFullHttpRequest不提供转换为ByteBuf的方法,因此我不能包含头

ByteBuf reqContent = getTestRequest();
DefaultFullHttpRequest reqHeader = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, url, reqContent);
ByteBuf headers = Unpooled.wrappedBuffer(reqHeader.headers().toString().getBytes());
client.post(url, clientRequest -> clientRequest.send(Flux.just(headers))).subscribe();

client.post(url, clientRequest -> clientRequest.send(Flux.just(reqHeader.content()))).subscribe(httpClientResponse -> log.debug("Successful" + httpClientResponse.status()),throwable -> log.error("exception " + throwable));
我看不到在哪里设置内容长度,如果我发送对象,我会看到头被写入两次:

一次,当我只发送内容时

14:39:46.645[reactor-http-nio-4]调试 r、 i.n.c.ChannelOperationsHandler-[id:0x85f9df60,L:/127.0.0.1:57054 -R:localhost/127.0.0.1:8092]编写对象DefaultHttpRequest(decodeResult:success,版本:HTTP/1.1)POST /xmlvend HTTP/1.1用户代理:ReactorNetty/0.6.3.RELEASE 传输编码:分块主机:本地主机:8092接受:/

然后再加上内容长度

14:39:46.650[reactor-http-nio-4]调试 r、 i.n.c.ChannelOperationsHandler-[id:0x85f9df60,L:/127.0.0.1:57054 -R:localhost/127.0.0.1:8092]写入对象DefaultFullHttpRequest(解码结果:成功,版本:HTTP/1.1, 内容:非OLEDHEAPByteBuf(ridx:0,widx:1511,cap:1511/1511)) POST/xmlvend HTTP/1.1内容长度:1511

是否没有办法使用reactor netty发送完整的httprequest,当然我不必使用正常的netty方式创建套接字等

谢谢