Proxyman iOS

1. Protocol Buffer

From Protobuf's Google, Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler.
You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages.
Proxyamn is capable of reading a Protobuf Binary and parsing to JSON Format with given Protobuf Schema.

2. Protobuf Schema

This guide describes how to use the protocol buffer language to structure your protocol buffer data, including .protofile syntax and how to generate data access classes from your .proto files.
Proxyman supports both proto2 and proto3 syntax. Read more

3. Protobuf Rules

Defind a Protobuf Config for matching URL:

3.1 Matching Rule:

Rule URL
Matching URL (Support wildcard)
Include all subpaths
All subpath of this URL is automatically matched
ANY or Exact certain HTTP Method

3.2 Protobuf Config:

Add .proto schema file if need
Message Type
The Class name of the root object in Protobuf binary. Must include Package name
Payload Type: Auto
Auto detect if the Protobuf Binary is encoding as a Single Message or Delimited Message
Payload Type: Single Message
Single Mesage in a Protobuf Binary
Payload Type: Delimited Message
Multiple Messages in a Protobuf Binary (Length-Prefix)

4. How to use?

There are two ways to parse Protobuf properly with qualified name fields:
  • Define Protobuf Rules
  • Read from Content-Type Header

4.1 Define Protobuf Rule

  1. 1.
    Make a request, which has Content-Type: application/x-protobuf or Content-Type: application/protobuf
  2. 2.
    You can see the Warning that Proxyman couldn't parse properly due to the absence of Message Type. Click Add to open Protobuf Settings
3. Add Schema and fill Message type and Payload Type
4. Click Add and see qualified JSON Format

4.2 Read from Content-Type Header

You can dynamically provide the Protobuf Config from Content-Type
For example: Your Content-Type in the Request or Response might look like:
Content-Type: application/x-protobuf; messageType="tutorial.Address"; delimited=true
Content-Type: application/x-protobuf; messageType="com.proxyman.User"; delimited=false
To specify that the Protobuf Body this MessageType and the payload encoding.

5. Troubleshooting

5.1 Some name fields are missing

There is a situation that some fieldnames are absent because the fieldname definition is not including in your Protobuf Schema List. It might be your Schema is out of date.
  • Remove old Protobuf Schema and Add a latest Schema from your server