@@ -227,13 +227,11 @@ public MerkleNode patch(Multihash base, String command, Optional<byte[]> data, O
227227 case "set-data" :
228228 if (!data .isPresent ())
229229 throw new IllegalStateException ("set-data requires data!" );
230- targetPath += "&arg=" +new String (data .get ());
231- return MerkleNode .fromJSON (retrieveMap (targetPath ));
230+ return MerkleNode .fromJSON (postMap (targetPath , data .get (), Collections .EMPTY_MAP ));
232231 case "append-data" :
233232 if (!data .isPresent ())
234233 throw new IllegalStateException ("append-data requires data!" );
235- targetPath += "&arg=" +new String (data .get ());
236- return MerkleNode .fromJSON (retrieveMap (targetPath ));
234+ return MerkleNode .fromJSON (postMap (targetPath , data .get (), Collections .EMPTY_MAP ));
237235 default :
238236 throw new IllegalStateException ("Unimplemented" );
239237 }
@@ -431,6 +429,11 @@ private static byte[] get(URL target) throws IOException {
431429 return resp .toByteArray ();
432430 }
433431
432+ private Map postMap (String path , byte [] body , Map <String , String > headers ) throws IOException {
433+ URL target = new URL ("http" , host , port , version + path );
434+ return (Map ) JSONParser .parse (new String (post (target , body , headers )));
435+ }
436+
434437 private static byte [] post (URL target , byte [] body , Map <String , String > headers ) throws IOException {
435438 HttpURLConnection conn = (HttpURLConnection ) target .openConnection ();
436439 for (String key : headers .keySet ())
0 commit comments