2013-11-26 51 views
3

我知道JSON RPC沒有硬規格,但我無法在此找到合適的解決方案。現在的問題是內容類型/什麼是正確的:JSON RPC v2 over HTTP的正確內容類型頭是什麼?

  1. 內容類型:應用程序/ JSON
  2. 內容類型:應用程序/ JSON-RPC
  3. 兩者兼而有之?

official (?) doc for v2v1有關於內容類型無關僅在this seemingly deprecated document大約JSON RCP V1.2有的定義(2),但可選的(1)。

通過研究使用第2版規範我的客戶,他們設置中發現的流行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; 
    } 

對我來說,最好的做法是隻接受既要對「安全」的一面?

回答

2

快速谷歌搜索後,我看到其他人使用application/json這是我所期望的JSON。由於文檔沒有指定,我想這可能會被打或取決於服務器的實現。

也許你可以實現一個例程,嘗試對方的壞迴應?不理想,但文檔不能幫助你很多。

+0

此來源? – for3st

相關問題