Bitcointalk · JSON-RPC Multiple Invocations

中本聪,2010 年 7 月 24 日

SN-1586 已核对来源,附原文与上下文。

阅读语言
中文译文

显然,重复头部是个 bug。

我当时是想遵循 1.0 规范:http://json-rpc.org/wiki/specification 它要求支持 multiple invocation。

我想他们的意思是下面这样,但不确定:

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 包真的支持 multiple invocation,多半没有。

最好先弄清楚 multiple-invocation 到底应该怎么工作(倘若真该支持的话),以及错误响应返回 HTTP 500 是否正确,再去修它。

ORIGINAL · 英文原文
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.

上下文
← 上一条 SN-1586 · 当前 下一条 → 在档案中查看完整主题串 →
来源
Bitcointalk 原始链接 ↗ 记录编号 SN-1586