Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

touge.restclient: allow POST and PUTs without content.

  • Loading branch information...
commit ef8ed00e24cef07a8139eccad584f6fff45f1b3c 1 parent 38ff97f
@kgilmer kgilmer authored
Showing with 19 additions and 15 deletions.
  1. +19 −15 org.touge.restclient/src/org/touge/restclient/ReSTClient.java
View
34 org.touge.restclient/src/org/touge/restclient/ReSTClient.java
@@ -627,24 +627,28 @@ public boolean removeConnectionInitializer(ConnectionInitializer initializer) {
connection.setDoOutput(false);
break;
case POST:
- connection.setDoOutput(true);
- baos = new ByteArrayOutputStream();
- copy(content, baos);
- writeRequestBody(connection, baos.toByteArray());
- baos.close();
+ if (content != null) {
+ connection.setDoOutput(true);
+ baos = new ByteArrayOutputStream();
+ copy(content, baos);
+ 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;
case PUT:
- connection.setDoOutput(true);
- baos = new ByteArrayOutputStream();
- copy(content, baos);
- writeRequestBody(connection, baos.toByteArray());
- baos.close();
-
- if (debugStream != null)
- debugMid(debugBuffer, new String(baos.toByteArray()));
+ if (content != null) {
+ connection.setDoOutput(true);
+ baos = new ByteArrayOutputStream();
+ copy(content, baos);
+ writeRequestBody(connection, baos.toByteArray());
+ baos.close();
+
+ if (debugStream != null)
+ debugMid(debugBuffer, new String(baos.toByteArray()));
+ }
break;
case DELETE:
connection.setDoInput(true);
Please sign in to comment.
Something went wrong with that request. Please try again.