Permalink
Browse files

restclient: tweaks to debug output

  • Loading branch information...
1 parent 08473d1 commit a02b50c5ba3b3a7b87a5a288bee12832990b250b @kgilmer kgilmer committed Oct 25, 2011
Showing with 9 additions and 4 deletions.
  1. +9 −4 org.touge.restclient/src/org/touge/restclient/ReSTClient.java
View
13 org.touge.restclient/src/org/touge/restclient/ReSTClient.java
@@ -608,7 +608,7 @@ public boolean removeConnectionInitializer(ConnectionInitializer initializer) {
public int getCode() throws IOException {
int code = connection.getResponseCode();
- if (debugStream != null) {
+ if (debugStream != null) {
responseBuffer = debugStart(code, connection.getResponseMessage());
}
@@ -666,7 +666,11 @@ public boolean isDone() {
@Override
public T getContent() throws IOException {
if (isError()) {
- if (responseBuffer != null) {
+ if (responseBuffer != null) {
+ byte[] errorMessage = readStream(connection.getErrorStream());
+ if (errorMessage != null && errorMessage.length > 0)
+ debugMid(responseBuffer, new String(errorMessage, "UTF-8"));
+
debugEnd(responseBuffer);
}
@@ -724,10 +728,11 @@ private StringBuilder debugStart(int responseCode, String responseMessage) {
StringBuilder debugBuffer = new StringBuilder();
debugBuffer.append(debugTimeFormat.format(new Date(System.currentTimeMillis())));
debugBuffer.append(' ');
- debugBuffer.append("HTTP Response ");
+ debugBuffer.append("<-- ");
debugBuffer.append(responseCode);
- debugBuffer.append(": ");
+ debugBuffer.append(" ");
debugBuffer.append(responseMessage);
+
debugBuffer.append(' ');
return debugBuffer;

0 comments on commit a02b50c

Please sign in to comment.