Skip to content

Commit

Permalink
touge.restclient: allow POST and PUTs without content.
Browse files Browse the repository at this point in the history
  • Loading branch information
kgilmer committed Nov 23, 2011
1 parent 38ff97f commit ef8ed00
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions org.touge.restclient/src/org/touge/restclient/ReSTClient.java
Expand Up @@ -627,24 +627,28 @@ public <T> Response<T> call(final HttpMethod method, final String url, final Res
connection.setDoOutput(false); connection.setDoOutput(false);
break; break;
case POST: case POST:
connection.setDoOutput(true); if (content != null) {
baos = new ByteArrayOutputStream(); connection.setDoOutput(true);
copy(content, baos); baos = new ByteArrayOutputStream();
writeRequestBody(connection, baos.toByteArray()); copy(content, baos);
baos.close(); writeRequestBody(connection, baos.toByteArray());
baos.close();


if (debugStream != null) if (debugStream != null)
debugMid(debugBuffer, new String(baos.toByteArray())); debugMid(debugBuffer, new String(baos.toByteArray()));
}
break; break;
case PUT: case PUT:
connection.setDoOutput(true); if (content != null) {
baos = new ByteArrayOutputStream(); connection.setDoOutput(true);
copy(content, baos); baos = new ByteArrayOutputStream();
writeRequestBody(connection, baos.toByteArray()); copy(content, baos);
baos.close(); writeRequestBody(connection, baos.toByteArray());

baos.close();
if (debugStream != null)
debugMid(debugBuffer, new String(baos.toByteArray())); if (debugStream != null)
debugMid(debugBuffer, new String(baos.toByteArray()));
}
break; break;
case DELETE: case DELETE:
connection.setDoInput(true); connection.setDoInput(true);
Expand Down

0 comments on commit ef8ed00

Please sign in to comment.