Repository navigation
Read Protobuf and MessagePack bodies - #13
Merged
Merged
Conversation
MessagePack describes itself, so a body whose media type says so needs no schema. Integers keep every digit up to 64 bits, bytes are hex, a map with keys that are not strings has them written as text, and a timestamp extension is an ISO 8601 date. A body that was cut, or that does not end where its last value does, is left to the hex dump.
With the descriptor set protoc writes, fields come out by name and type: enums by name, maps as objects, packed and unpacked repeated numbers as lists, a duration and a timestamp as one string, and fields the schema does not know by their number. Without one they come out by field number, with a length delimited field taken for text, a message or bytes the way protoc --decode_raw takes it. A gRPC or gRPC-web call finds its message types from the method in its address, lists the messages of a stream and shows the trailers.
The viewer asks the decoders the app registered first, then MessagePack, then Protobuf by field number. Decoding happens when a body is opened, so the capture is untouched.
|
This pull request adds no capability the code did not already have. 31 files read · 2155 ms · against |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #12: its commits are in this branch, and GitHub moves the base to
mainwhen #12 is merged. The diff here is the decoders, plus the two commits at the end, which the last paragraph describes.Protobuf and MessagePack bodies were a hex dump unless the app wrote a decoder. Both now have one, and the inspector registers the ones that need no schema.
MessagePack describes itself, so a body whose media type says MessagePack (
application/msgpack,application/x-msgpack,application/vnd.msgpack, a+msgpacksuffix) is shown as indented text with no setup. Integers keep every digit up to 64 bits, bytes are hex, a map with keys that are not strings has them written as text, and the timestamp extension is an ISO 8601 date.Protobuf has two modes:
FlutwireProtobufDecoder(descriptorSet: ...), which takes the descriptor set thatprotocwrites with--descriptor_set_outand--include_imports: fields by name and type, enums by name, maps as objects, packed and unpacked repeated numbers as lists,TimestampandDurationas one string each, and fields the schema does not know by their number.messageTypesays which message a body is when it is not gRPC.protoc --decode_rawtakes it.A gRPC or gRPC-web call (
application/grpcorapplication/grpc-web, with or without+proto) finds its message types from the method in its address, lists the messages of a stream and shows the trailers. A compressed message is marked as such, because the decoder has no algorithm to run.Both decoders leave a body alone when it was cut or does not end where its last value does. They run when a body is opened, so the capture is untouched, and they are plain Dart with no
dart:io, so they work on the web. The wire reader keeps 64 bit numbers exact by moving frominttoBigIntpast 2^53.I could not cross-check the Protobuf side against
protochere, because the Homebrew build fails to load abseil. The tests use messages and descriptors encoded by hand from the encoding guide anddescriptor.proto, including the guide's own examples. A descriptor set from a real API is worth one run before 0.2.0.I tried it on an Android emulator with the example app, which has a MessagePack body and a Protobuf body now. All four suites pass,
flutter analyze --fatal-infosis clean and the example builds for the web.The last two commits come from a review of #12 and of this branch, and neither changes behaviour. One compiles three regular expressions once instead of on every call and copies a cut message once instead of twice. The other gives the three files that import
dart:ioand did not say so (websocket_reader,wire_socketanddisk_store) the_iosuffix that the other five carry.Targets
0.2.0, Tier 2, M22.