原始文献 / 论坛帖 / Re: JSON-RPC Multiple Invocations

Re: JSON-RPC Multiple Invocations

Bitcointalk · 2010-07-24 00:59:08 UTC

AuthorSatoshi Nakamoto
TitleRe: JSON-RPC Multiple Invocations
Date2010-07-24 00:59:08 UTC
ForumBitcointalk · 原文

它重复 header 显然是个 bug。

我是想遵循 1.0 规范:http://json-rpc.org/wiki/specification 它要求支持多次调用。

我想它的意思是这样的,但我不确定:

Post:
{"method": "postMessage", "params": ["Hello all!"], "id": 99}
{"method": "postMessage", "params": ["I have a question:"], "id": 101}

Reply:
{"result": 1, "error": null, "id": 99}
{"result": 1, "error": null, "id": 101}

我记不清在哪看到的,说错误回复应该返回 HTTP 状态 500。如果一次回复里有多个响应、其中一个是错误,那整个是不是都算 500,我猜是。也许应该永远返回 200。我记得有人说过 500 可能在惹麻烦。

这大概在 0.3.3 之后修。在那之前,只用单次调用。我怀疑有没有 JSON-RPC 包支持多次调用,大概没有。

要是能在修之前先把多次调用到底该怎么工作(如果该支持的话)定下来就好了,还有错误响应返回 HTTP 状态 500 到底对不对。

英文原文

Obviously it's a bug that it repeats the header.

I was trying to follow the 1.0 spec: http://json-rpc.org/wiki/specification It called for multiple invocation.

I think they mean it's like this, but I'm not sure:

Post:
{"method": "postMessage", "params": ["Hello all!"], "id": 99}
{"method": "postMessage", "params": ["I have a question:"], "id": 101}

Reply:
{"result": 1, "error": null, "id": 99}
{"result": 1, "error": null, "id": 101}

I can't remember where I think I saw that it's supposed to send back HTTP status 500 for an error reply. If it contains multiple responses and one is an error, I wonder if that makes the status 500 for the whole thing, I guess so. Maybe it should always return 200. I think someone sounded like the 500 might be causing a problem.

This probably gets fixed after 0.3.3. Until then, just use single invocation. I wonder if any JSON-RPC package even supports multiple invocation, probably not.

It would be nice if we could pin down better how multiple-invocation is supposed to work, if at all, before trying to fix it, and whether returning HTTP status 500 for error response is right.