jnan77 / jsonrpc4j

Automatically exported from code.google.com/p/jsonrpc4j
0 stars 0 forks source link

JsonRpcHttpClient always sets its own Content-Type header even if one was specified. #67

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Try using the http client against XBMC:
Map<String,String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");

JsonRpcHttpClient client = new JsonRpcHttpClient(
            new URL("http://xbmc:8080/jsonrpc"),headers);

client.invoke("GUI.ShowNotification", new Object[] {"Test", "Hello world"});

What is the expected output? What do you see instead?
Expexted a notification but geting a 415 http error response code.

Please provide any additional information below.
Fixed it by adding a check to the http client for a content type.
From:
con.setRequestProperty("Content-Type", "application/json-rpc");

To:
if(!headers.containsKey("Content-Type")) {
    con.setRequestProperty("Content-Type", "application/json-rpc");
}

Original issue reported on code.google.com by joa...@gmail.com on 2 Oct 2013 at 11:12

GoogleCodeExporter commented 8 years ago
I'll look into this.  The problem is that "application/json" isn't the 
"correct" content-type for json-rpc.

Original comment by brian.di...@gmail.com on 18 Oct 2013 at 11:14

GoogleCodeExporter commented 8 years ago
moving to github: https://github.com/briandilley/jsonrpc4j/issues

Original comment by brian.di...@gmail.com on 18 Oct 2013 at 11:29