【发布时间】:2013-12-11 19:04:22
【问题描述】:
我知道 JSON RPC 不是直接用 HTTP 指定的,但我找不到合适的解决方案。问题是,哪个content-type 是正确的:
content-type: application/jsoncontent-type: application/json-rpc- 两者都有?
在official (?) doc for v2 和v1 中没有关于内容类型的内容,只有在this seemingly deprecated document 关于 JSON rcp v1.2 中有 (2) 的定义,但 (1) 是可选的。
通过调查使用 v2 规范的流行 jsonRPC4J java lib,我在他们设置的客户端中发现 (2):
/**
* Prepares a connection to the server.
* @param extraHeaders extra headers to add to the request
* @return the unopened connection
* @throws IOException
*/
protected HttpURLConnection prepareConnection(Map<String, String> extraHeaders)
throws IOException {
...
con.setRequestProperty("Content-Type", "application/json-rpc");
// return it
return con;
}
对我来说,最好的做法是接受两者都处于“安全”方面?
【问题讨论】:
标签: json http http-headers content-type json-rpc