mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-23 12:10:33 +08:00
tweaks (#1788)
* tweak * opt: show bar * opt: crc32 * opt: appsign * opt: Get * opt: compress only if large * opt: wbi * tweak Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> --------- Signed-off-by: My-Responsitories <107370289+My-Responsitories@users.noreply.github.com> Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
committed by
GitHub
parent
31e5692dff
commit
521ca3ad18
@@ -12,6 +12,7 @@ import 'package:protobuf/protobuf.dart' show GeneratedMessage;
|
||||
|
||||
abstract final class GrpcReq {
|
||||
static const _isolateSize = 256 * 1024;
|
||||
static const _gzipMinLength = 64;
|
||||
|
||||
static final options = Options(
|
||||
contentType: 'application/grpc',
|
||||
@@ -19,9 +20,12 @@ abstract final class GrpcReq {
|
||||
);
|
||||
|
||||
static Uint8List compressProtobuf(Uint8List proto) {
|
||||
proto = const GZipEncoder().encodeBytes(proto);
|
||||
final compress = proto.length > _gzipMinLength;
|
||||
if (compress) {
|
||||
proto = const GZipEncoder().encodeBytes(proto);
|
||||
}
|
||||
return Uint8List(5 + proto.length)
|
||||
..[0] = 1
|
||||
..[0] = compress ? 1 : 0
|
||||
..buffer.asByteData(1, 4).setInt32(0, proto.length, Endian.big)
|
||||
..setAll(5, proto);
|
||||
}
|
||||
@@ -48,7 +52,7 @@ abstract final class GrpcReq {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<T>> request<T>(
|
||||
static Future<LoadingState<T>> request<T extends GeneratedMessage>(
|
||||
String url,
|
||||
GeneratedMessage request,
|
||||
T Function(Uint8List) grpcParser, {
|
||||
|
||||
Reference in New Issue
Block a user