在注释服务中处理 Content-Encoding gzip
Handle Content-Encoding gzip in Annotated Service
我有一个带注释的服务。一些客户端 POST 以明文形式请求内容。其他客户端 POST 请求压缩并包含 header Content-Encoding: gzip
.
gzipped 请求无法解码为 proto 值,因为它们没有先解压缩。
如何装饰我的操作,以便它根据 header 值有选择地压缩 body?
@Post("/foo/bar)
@Consumes("application/x-protobuf")
@Produces("application/x-protobuf")
fun setFooBar(
request: SetFooBarRequest,
headers: RequestHeaders,
): SetFooBarResponse { ... }
因 Protocol message tag had invalid wire type.
而失败(即此 blob 不是原型值),但仅适用于 Content-Encoding: gzip
的请求
默认情况下,DecodingService 会自动解码 gzip
、deflate
和 brotli
。您可以使用 ServerBuilder.decorate()
申请 DecodingService
。
例如:
Server.builder()
.annotatedService(new MyProtobufService())
.decorate(DecodingService.newDecorator()) //
.build();
我有一个带注释的服务。一些客户端 POST 以明文形式请求内容。其他客户端 POST 请求压缩并包含 header Content-Encoding: gzip
.
gzipped 请求无法解码为 proto 值,因为它们没有先解压缩。
如何装饰我的操作,以便它根据 header 值有选择地压缩 body?
@Post("/foo/bar)
@Consumes("application/x-protobuf")
@Produces("application/x-protobuf")
fun setFooBar(
request: SetFooBarRequest,
headers: RequestHeaders,
): SetFooBarResponse { ... }
因 Protocol message tag had invalid wire type.
而失败(即此 blob 不是原型值),但仅适用于 Content-Encoding: gzip
DecodingService 会自动解码 gzip
、deflate
和 brotli
。您可以使用 ServerBuilder.decorate()
申请 DecodingService
。
例如:
Server.builder()
.annotatedService(new MyProtobufService())
.decorate(DecodingService.newDecorator()) //
.build();