mqtt: WIP: Read variable header indepentenly from payload #13465
+46
−2
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.
Started by me in a discussion at #13448
current upstream implementation
The MQTT publish packet sent by a broker to a subscribing client is only parsed for the fixed header indicating the packet type.
However, the packet itself still contains a variable header indicating the topic length, topic and packet ID. http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718039 (Section 3.3.2)
The whole variable header and the following payload is output by the curl tool. Yet, we know that the first two bytes are the topic length, which, given that it is significantly short, results in the first byte being
x00
. That results in curl aborting the output and warning of binary output. This makes curl unsuitable for testing any MQTT functionality on the command line.proposed change
Break the current implementation and provide the variable header values topic and header ID as header values hidden behind a -v flag like with HTTP.
The output will now only be the actual payload of the packet.
You may want to test this with the
-N
flag. Otherwise you won't see the output immediately.further discussion points
Curl_client_write(data, CLIENTWRITE_HEADER,...
does not what I expect it to do, also no way to set the header name, is it even the correct approach?