Riap::Simple - Simple Riap protocol over any stream socket
This document describes version 1.1.24 of Riap::Simple (from Perl distribution Riap), released on 2014-08-18.
This document specifies a simple Riap protocol over any stream socket like TCP, Unix, or piping to program.
Riap::Simple is a simpler alternative to Riap::HTTP. It supports less features (currently only supports sending/receiving Riap request and response in JSON encoding, no encryption, no authentication, no sending of logging messages). It is suitable for localhost/localnet communication (e.g. between processes of different languages). For public-facing service, Riap::HTTP is more recommended.
Client first sends a request line of the following format:
"J" <size> <CRLF>
That is, the uppercase letter J (for JSON) and size of subsequent request body in bytes. Client then sends the Riap request in JSON, followed by CRLF.
J
Alternatively, client can also send the whole request in a single line, for shorter requests:
"j" <JSON> <CRLF>
That is, the lowercase letter j followed by JSON data, followed by CRLF. In this format, the JSON data cannot contain newlines.
j
Server replies by first sending a similar line:
followed by enveloped result encoded in JSON and a single <CRLF>. The next request can then be sent by client.
If client/server sends an invalid request/response line, the connection can be closed.
1.1
Below are some examples of what is sent and received on the wire.
J9 {"v":0.9} J40 [502,"Protocol version not implemented"] J1 { J20 [400,"Invalid JSON"] J57 {"action":"call","uri":"/Math/mult","args":{"a":2,"b":3}} J12 [200,"OK",6] j{"action":"call","uri":"/Math/mult","args":{"a":2,"b":4}} J12 [200,"OK",8] J44 {"v":1.1,"action":"info","uri":"/Math/mult"} J57 [200,"OK",{"v":1.1,"type":"function","uri":"/Math/mult"}]
Riap, Riap::HTTP
Please visit the project's homepage at https://metacpan.org/release/Riap.
Source repository is at https://github.com/sharyanto/perl-Riap.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Riap
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Steven Haryanto <stevenharyanto@gmail.com>
This software is copyright (c) 2014 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Riap, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Riap
CPAN shell
perl -MCPAN -e shell install Riap
For more information on module installation, please visit the detailed CPAN module installation guide.