Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Fix #15 and #16 by specifying a default path like is already done on …
Browse files Browse the repository at this point in the history
…`get` and make `delete` work consistently like the other commands by not making a path value mandatory. Also fixed a bug where an empty body returned by the server, if the content-type was `application/json`, would cause an NPE in the parsing code.
  • Loading branch information
Jon Brisbin authored and jbrisbin committed Nov 12, 2012
1 parent 9c4d369 commit 67073e7
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ public String post(
public String put(
@CliOption(key = {"", "rel"},
mandatory = false,
help = "The path to the resource.") PathOrRel path,
help = "The path to the resource.",
unspecifiedDefaultValue = "") PathOrRel path,
@CliOption(key = "data",
mandatory = true,
help = "The JSON data to use as the resource.") String data,
Expand Down Expand Up @@ -276,8 +277,9 @@ public String put(
@CliCommand(value = "delete", help = "Issue HTTP DELETE to delete a resource.")
public String delete(
@CliOption(key = {"", "rel"},
mandatory = true,
help = "Issue HTTP DELETE to delete a resource.") PathOrRel path,
mandatory = false,
help = "Issue HTTP DELETE to delete a resource.",
unspecifiedDefaultValue = "") PathOrRel path,
@CliOption(key = "follow",
mandatory = false,
help = "If a Location header is returned, immediately follow it.",
Expand Down Expand Up @@ -545,7 +547,7 @@ private RequestHelper(Object body, MediaType contentType) {
contextCmds.variables.put("responseBody", null);

MediaType ct = response.getHeaders().getContentType();
if(null != ct && ct.getSubtype().endsWith("json")) {
if(null != body && null != ct && ct.getSubtype().endsWith("json")) {
// Pretty-print the JSON
if(body.startsWith("{")) {
lastResult = mapper.readValue(body.getBytes(), Map.class);
Expand Down

0 comments on commit 67073e7

Please sign in to comment.