Hello!
2015-10-20 21:22 GMT+08:00 jun ni:
> receiveuntil 确实是这样的逻辑,但是从case的结果上看是:读取非最后一个分片时,读到的data size < chunk_size;
> 但是并不是直接返回err: timeout 或者 client
> aborted;而是先返回了部分的data,后面我再读取一次时,才返回err。但是刚才上一次部分data却是返回了。。。很奇异,我再看看能不能复现吧,谢谢春哥
>
和 receive(size) 方法不同,receiveuntil() 返回的迭代器的 size
参数是建议性的,实际返回的数据块大小可能更大一些,也可能更小一些。所以你描述的行为倒也算是正常的行为。引用一下对应的官方文档对
receiveuntil 返回的迭代器的 chunk size 参数的描述:
“Note that, the actual data returned might be a little longer than the
size limit specified by the sizeargument when the boundary pattern has
ambiguity for streaming parsing. Near the boundary of the data stream,
the data string actually returned could also be shorter than the size
limit.”
Regards,
-agentzh