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.
Based off the work in https://github.com/jesec/rtorrent, this implements the 2.0 specification: https://www.jsonrpc.org/specification. It adds a new RpcManager class and a little SCGI logic to handle switching between XML and JSON seamlessly. If the
CONTENT_TYPE
header is present and set toapplication/json
(ortext/xml
for XML-RPC), it'll use that, otherwise it will peek at the body to auto-detect it.The main benefit is reduced message size, as seen on this synthetic set of 10k torrents:
One limitation of JSON-RPC is that it doesn't have a dedicated binary data type. Due to that, base64 data URI support has been added to all the
load.*
commands. Those are currently the only commands which normally need to take binary data, but any future commands would have to follow the same pattern or implement their own scheme.Note for Flood users
When Flood detects the presence of JSON-RPC, it assumes that the full jesec/rtorrent capabilities are available, which breaks a couple things. Thankfully, it's pretty easy to provide some stubs/redirects to get it working: