Poor man's http protocol for transporting a status/run line, a header block and a content block
The http protocol is good, but very difficult to parse and is too complicated to implement. During the development of one of my projects, I needed a very lightweight solution for transmitting messages between internal services, so this protocol is developed.
The protocol is built on a TCP connection and is intended for LAN usage. Messages are transmitted as a stream of blocks without deduplication. TLS could be implemented over raw TCP streams for added security.
The request message consists of a run line block, a headers block, and data blocks.
The run message consists of a response line block, a headers block, and data blocks.
Each block contains its message id for potential interleaved blocks. Block is formatted as following:
int32_le message_id;
int32_le block_size;
byte[block_size] content;
Data-blocks are sequences in the same order as they appeared in the stream.
int32_le utf8_length;
char8_t[utf8_length] content;
phttp_string verb;
phttp_string version;
phttp_string resource_location;
int32_le http_status_code;
phttp_string http_response_message;
int32_le entry_count;
phttp_string[entry_count][2] header_entries;