You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "sick-cat (via GitHub)" <gi...@apache.org> on 2023/08/14 04:18:47 UTC
[GitHub] [dubbo] sick-cat commented on issue #12891: rest 接口响应内容大于1kb时触发分块传输,导致报错
sick-cat commented on issue #12891:
URL: https://github.com/apache/dubbo/issues/12891#issuecomment-1676648278
org.apache.dubbo.rpc.protocol.rest.netty.NettyHttpResponse中通过一下方式创建outputstream
```java
os = new ChunkOutputStream(this, ctx, 1000);
```
org.apache.dubbo.rpc.protocol.rest.netty.ChunkOutputStream 会分块处理长度超过1000的响应内容。
```java
public void write(byte[] b, int off, int len) throws IOException {
int dataLengthLeftToWrite = len;
int dataToWriteOffset = off;
int spaceLeftInCurrentChunk;
while ((spaceLeftInCurrentChunk = buffer.maxWritableBytes()) < dataLengthLeftToWrite) {
buffer.writeBytes(b, dataToWriteOffset, spaceLeftInCurrentChunk);
dataToWriteOffset = dataToWriteOffset + spaceLeftInCurrentChunk;
dataLengthLeftToWrite = dataLengthLeftToWrite - spaceLeftInCurrentChunk;
flush();
}
if (dataLengthLeftToWrite > 0) {
buffer.writeBytes(b, dataToWriteOffset, dataLengthLeftToWrite);
}
}
```
org.apache.dubbo.rpc.protocol.rest.extension.resteasy.filter.ResteasyResponseContainerFilterAdapter会在 `restOutputStream(response);` 时触发异常
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org