jsonrpc: make "jsonrpc" request field optional

The "jsonrpc" field, per spec, is meant to contain the exact string
"2.0" to indicate the version of the JSON-RPC specification implemented
by the client.  We don't do anything useful with this information except
to drop requests for (theoretical) other versions, so it should be safe
to allow the parameter to be optional.  If the version is specified, we
will still validate that it is 2.0.

This enables interoperability with a Go JSON-RPC client, as mentioned in
issue #303: https://godoc.org/github.com/mafredri/cdp/rpcc

Change-Id: Ifde32b3f47a5d7942f4ab74b4d6029dd0168efa8
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/411742
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Daniel Verkamp 2018-05-18 09:05:36 -07:00 committed by Jim Harris
parent 700477897a
commit aa67900a2e

View File

@ -71,8 +71,8 @@ parse_single_request(struct spdk_jsonrpc_request *request, struct spdk_json_val
goto done;
}
if (!req.version || req.version->type != SPDK_JSON_VAL_STRING ||
!spdk_json_strequal(req.version, "2.0")) {
if (req.version && (req.version->type != SPDK_JSON_VAL_STRING ||
!spdk_json_strequal(req.version, "2.0"))) {
invalid = true;
}