#2895·grpc-rust

tonic-web: GrpcWebCall 大小 hint 与被翻译的正文不符

作者: polaz创建于 2026年9月28日更新于 2026年9月28日

□ 错误报告

翻译:

通心粉 v0.14.6 (韩语).
甲状腺素健康 v0.14.6
(原始内容存档于2013-10-12). tonic-web v.0.14.6

主人的密码一样

+++ 平台

达尔文 25.6.0 arm64 (macOS),生锈 1.98.0

rate rate

托尼网络

说明

‘GrpcWebCall:: small hint' 返回内体的提示,但是它产生的身体 有不同的长度: Base64 解码缩小了 grpc-web-text 请求, 编码会生成一个响应,拖车会被添加到数据中或者从数据中取出. 超音速发送精确的提示为“ 内容长度 ” , 所以一个翻译后的消息 在网络上发布错误的长度。

我尝试了这个代码,一个grpc-web 在远程服务器前的gRPC网关:

zz
使用基数64:引擎为 ;
使用 http body util: :{BodyExt, Full};
使用塔:{Layer, ServiceExt};

# [tokio:main] (英语).
async fn 主线 () {
让收听者=tokio:net:Tcp收听者:bind("127.0.0.1:0"). await.unwrap();
让添加器=收听器. local addr (. unwrap ();
let ( reporter, health) = tonic health: server: health reporter ();
tokio: 发芽( S):
通心粉::运输:服务:建设()
add 服务(健康)
.serve  with incoming(tokio stream:: wrappers::TcpListener Stream::: new( listener)),",",",",",",",",","
(三)

let channel = tonic: transport:::: from share(format! ("http://{addr}"))).
. unrap () (中文(简体) ).
连接( )
等待着
.unrap( ); (中文(简体) ).
让网关 = tonic web:GrpcWebLayer:: new (.)layer(频道);

//grpc-web-text 带有空信件的“检查”;“Full”有确切长度,
/ 如`内容长度 ' 的要求。
让正文 = 基数64: engine: general xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
让 request = http:request: post ("/grpc.health.v1. Health/Check").
.header ("内容类型","应用程序/grpc-web-text")
.header ("接受","应用/grpc-web-text") (中文(简体) ).
.body(音:body:body:Body::neew(音:ful:neew(body.into bytes (.into ()))).
.unrap( ); (中文(简体) ).

让回复=网关. oneshot(请求).await.unwrap();
让正文=响应. into body (. collect (. await.unwrap (.).to bytes ();
println ("Q"), 字符串 : from  utf8  lossy( &body) );
{\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你觉得呢?

我本想看到这种情况的发生: 呼叫成功,就像二进制一样 grpc-web或服务正在进行中.

相反,发生了这种情况:请求与基数64长度(8)相呼应。 5个字节的 " 内容长 " ,服务器将流重排:

tonic:: transport:: Error( Transport, 超能:: Error (Http2, 错误{类型: 重置(StreamId(1), Communicipal ERROR, 远程)})).

2896号可能已经修好了